@rem @rem Written By: Michael Gupton @rem Date Created: 4/15/2014 @rem @rem Description: @rem @rem This script is designed to be used to uninstall the @rem WLC Log Agent in an automated fashion. @rem @rem Dependencies: @rem @rem msiexec.exe @rem @rem Compatibility: @rem @rem Windows Server 2003 or later @rem @rem Usage: @rem @rem This script could be used in Windows domain environment @rem by configuring a one-time scheduled task as a GPO that gets @rem pushed to domain members with a Group Policy. @rem @rem This script could also be used with a configuration @rem management tool. @rem @rem Alternatively, it could be ran on a single host @rem that has remote access to the targeted systems. @rem Using the gratis Microsoft tool psexec this @rem could be remotely executed on the targeted systems. @rem @rem Notes: @rem @rem This script extracts the GUID that identifies @rem the WLC Agent on the system. @rem Using the GUID to do the uninstall means @rem the installer msi package is not needed, @rem which faciliates automated uninstallation. @rem @rem There are easier ways to do this with Powershell @rem the wmic command but those dependicies are not @rem always avaialble on Windows Server 2003 @rem for example. @rem @ECHO off Setlocal EnableDelayedExpansion @REM If this registry key exists the script is running on a 64-bit system. reg query HKLM\Software\Wow6432Node > nul 2 > nul IF %errorlevel%==0 ( @REM 64-bit SET REGPATH=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall SET ARCH=64BIT ) ELSE ( @REM 32-bit SET REGPATH=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall SET ARCH=32BIT ) FOR /f "delims=" %%i IN ('reg query %REGPATH%') DO ( SET KEY=%%i @REM Parse each line of the reg query output into tokens and save last token which represents the GUID. IF /I "!ARCH!"=="64BIT" ( FOR /F "tokens=1-8 delims=\" %%G IN ("!KEY!") DO SET GUID_EX=%%N ) ELSE ( FOR /F "tokens=1-7 delims=\" %%G IN ("!KEY!") DO SET GUID_EX=%%M ) @REM For the token that represents the GUID remove the enclosing { and } characters. FOR /F "delims={,}" %%A IN ("!GUID_EX!") DO SET GUID=%%A SET CMD=reg query "!KEY!" /v DisplayName @REM Extract just the DisplayName from the registry. FOR /F "tokens=2*" %%B IN ('!CMD! 2^>NUL ^| FIND /I " DisplayName "') DO SET name=%%C @REM If the DisplayName matches "AL Agent" then use the GUID to uninstall the agent. @REM Reboots are generally not needed to uninstall the agent but to be sure @REM that automatic reboots do not happen the option to suppress reboots is used. IF /I "!name!"=="AL Agent" ( msiexec /x {!GUID!} /qn /norestart REBOOT=ReallySuppress RMDIR "C:\Program Files (x86)\AlertLogic" /s /q RMDIR "C:\Program Files (x86)\Common Files\AlertLogic" /s /q ECHO The uninstall script has completed. GOTO END ) )