@echo off

REM Delete main just this program and its folder
if exist "c:\Program Files\SchoolsTools\Control8" rmdir /s /q "c:\Program Files\SchoolsTools\Control8"

REM Check the SchoolsTools directory for other installations - leave it alone if there are others, delete if not
dir "c:\Program Files\SchoolsTools" | find " 2 Dir(s)" > NUL
if errorlevel 1 goto delShortcuts
rmdir /s /q "c:\Program Files\SchoolsTools"

REM Delete the shortcuts
:delShortcuts

ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto W2KXP

ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto W2KXP

if not exist %SystemRoot%\system32\systeminfo.exe goto notFound

systeminfo | find "OS Name" > %TEMP%\osname.txt
FOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i

echo %vers% | find "Windows Vista" > nul
if %ERRORLEVEL% == 0 goto WV7

echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto WV7

goto notFound

:W2KXP
if exist "c:\Documents and Settings\All Users\Start Menu\Programs\Schools Tools\Control 8" rmdir /s /q "c:\Documents and Settings\All Users\Start Menu\Programs\Schools Tools\Control 8"
dir "c:\Documents and Settings\All Users\Start Menu\Programs\Schools Tools" | find " 2 Dir(s)" > NUL
if errorlevel 1 goto ending
rmdir /s /q "c:\Documents and Settings\All Users\Start Menu\Programs\Schools Tools"

goto ending

:WV7
if exist "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\Schools Tools\Control 8" rmdir /s /q "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\Schools Tools\Control 8"
dir "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\Schools Tools" | find " 2 Dir(s)" > NUL
if errorlevel 1 goto ending
rmdir /s /q "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\Schools Tools"

:ending
echo Uninstallation Complete!
pause