@echo off
if "%1" == "" goto usage
if "%2" == "" goto usage
if not exist %1:\%2\nul goto usage

echo Deinstalling Microsoft Systems Management Server March '94 Beta
echo Hit [Ctrl-C] now if this is not your intention...
pause
echo De-installing all Microsoft Systems Management Services...

rmvsvc.exe
echo. 
echo Removing sms shares
echo.
net share /d SMS_SHR
net share /d SMS_SHR%1
net share /d SMS_SITE
echo.
echo Removing hermes directories...
attrib -h c:\sms.ini
del c:\sms.ini
pause

if exist c:\ms\sms\nul delnode /q c:\ms\sms
if exist c:\ms\sms\nul goto cantdel2

if exist %1:\%2\nul delnode /q %1:\%2
if exist %1:\%2\nul goto cantdel

echo.
echo Now you must delete the SMS registry entries.
echo The Registry editor will be automatically started.
echo From the registry window, select the proper HKEY, 
echo find the proper path, and select the given registry 
echo entry.  Then press delete, and answer YES.
echo.
echo Registry entries to be deleted (if they exist) follow:
echo HKEY               Path                 
echo HKEY_LOCAL_MACHINE SOFTWARE\MICROSOFT\SMS
echo HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\Services\EventLog\Applications\SMS
echo HKEY_CURRENT_USER  SOFTWARE\MICROSOFT\SMS
echo.
echo After you delete the registry keys, you should use the 
echo SQL Administrator tool to drop the SMS database (at Primary
echo Sites only).  You should also delete all SMS-related Program
echo Groups and/or Program Items (i.e. in the Startup Group).
echo.
echo Press any key to start regedit...
pause 
start regedt32
echo.

echo END of Systems Management Server Deinstallation...
goto end

:cantdel
echo Can't delete Systems Management Server directory.
echo Possible Causes:
echo A Systems Management Service is still running.
echo.
echo The Systems Management Server User Interface is still running.
echo.
echo The event viewer is viewing Systems Management Server events.
echo.
echo Shares within the SMS directory still exist (MAC volumes, etc.)
echo.
echo A command prompt or the file manager is currently open to a subdirectory
echo of the Systems Management Server %1:%2 directory.
echo.
echo Please fix the problem and restart this command file.
echo.
goto end

:cantdel2
echo Can't delete the SMS Client directory (ms).  Please use pview
echo to kill all SMS client processes (PCM*.EXE, APP*.EXE).
goto end

:usage
echo SMS Deinstallation -- Usage
echo delsms drive installdir
echo where
echo    drive - the drive SMS is installed on (no colon)
echo    installdir - the director where sms is installed
echo.
echo i.e. delsms c SMS

:end
pause

