
set SymEntLog=logs\SymEvntUnst.Log

call :GetSymEvtApps
call :RemoveSymEvent

ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\S32EVNT1.DLL" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\SYMEVNT.386" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\SYMEVNT1.DLL" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\drivers\SYMEVENT.CAT" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\drivers\SYMEVENT.INF" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\drivers\SYMEVENT.SYS" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\drivers\SYMEVENT64x86.CAT" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\drivers\SYMEVENT64x86.INF" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%SystemRoot%\system32\drivers\SYMEVENT64x86.SYS" > NUL

ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFilesX%\Symantec\SYMEVNT.386" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFilesX%\Symantec\SYMEVNT1.DLL" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFilesX%\Symantec\S32EVNT1.DLL" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFilesX%\Symantec\SYMEVENT.SYS" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFilesX%\Symantec\SYMEVENT.INF" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFilesX%\Symantec\SYMEVENT.CAT" > NUL

ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVNT.386" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVNT1.DLL" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\S32EVNT1.DLL" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVENT.SYS" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVENT.INF" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVENT.CAT" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVENT64x86.SYS" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVENT64x86.INF" > NUL
ESUGUnEn /LF%SymEntLog% /delfile"%ProgramFiles%\Symantec\SYMEVENT64x86.CAT" > NUL

ESUGUnEn /LF%SymEntLog% /delfile"%CommonProgramFiles%\Symantec Shared\Sevinst.exe" > NUL

goto :eof

rem *************************************************************************************
rem *************************************************************************************
rem **********     Subroutines     ******************************************************
rem *************************************************************************************
rem *************************************************************************************

:GetSymEvtApps
REM :GetSymEvtApps
set MakeLast=
if exist SymEvtRegApps.txt del /q SymEvtRegApps.txt
if exist SymEvtApps.txt del /q SymEvtApps.txt
ESUGENum.exe /k HKEY_LOCAL_MACHINE "%LargeOS%\Symantec\Symevent" > SymEvtRegApps.txt
if not exist SymEvtRegApps.txt goto :eof
for /f "delims=$" %%a in (SymEvtRegApps.txt) do (set hivename="%%a") & (call :GetSymHives)
if exist SymEvtRegApps.txt del /q SymEvtRegApps.txt
if defined MakeLast (echo.%MakeLast%>>SymEvtApps.txt)
if not exist "SymEvtApps.txt" goto :eof
echo Applications listed as using SymEvent per HKEY_LOCAL_MACHINE\%LargeOS%\Symantec\Symevent: >> %SymEntLog%
type SymEvtApps.txt>> %SymEntLog%
echo.>> %SymEntLog%
goto :eof

:GetSymHives
REM :GetSymHives
set hivename=%hivename:"=%
if /i "%hivename%"=="" goto :eof
if /i "%hivename%"=="Failed to Open registry..." goto :eof
if /i %hivename%==VDD goto :eof
if /i %hivename%==SAVCE (set MakeLast=%Hivename%) & (goto :eof)
if /i %hivename%==NAVNT (set MakeLast=%Hivename%) & (goto :eof)
echo.%hivename%>>SymEvtApps.txt
goto :eof

:RemoveSymEvent
REM :RemoveSymEvent
if not exist "SymEvtApps.txt" (echo No applications found tied to SymEvent.>> %SymEntLog%) & goto :eof
echo.>> %SymEntLog%
echo ######### Uninstalling SymEvent >> %SymEntLog%
for /f "delims=$" %%a in (SymEvtApps.txt) do call :UnInstallSymEvt %%a
if exist SymEvtRegApps.txt del /q SymEvtRegApps.txt
if exist SymEvtApps.txt del /q SymEvtApps.txt
goto :eof

:UnInstallSymEvt
REM :UnInstallSymEvt
set ProdID=
set ProdID=%1
echo.>> %SymEntLog%
echo ######### Uninstalling SymEvent for Product ID %ProdID% >> %SymEntLog%
SEVINST.EXE /U /Q /LOG /%ProdID% /NODEL > NUL
echo.>> %SymEntLog%
if exist "%windir%\Symevent.log" (type "%windir%\Symevent.log" >> %SymEntLog%)
if exist "%windir%\Symevent.log" ESUGUnEn /LF%SymEntLog% /delfile"%windir%\Symevent.log" > NUL
echo.>> %SymEntLog%
goto :eof
