home *** CD-ROM | disk | FTP | other *** search
/ ftp2.jacobs.com / 2015.02.ftp2.jacobs.com.tar / ftp2.jacobs.com / altiris.exe / Uninstall-SM-Agents.exe / RemoveAltiris.cmd < prev    next >
OS/2 REXX Batch file  |  2010-08-18  |  26KB  |  330 lines

  1. @ECHO OFF||                    :: Turns off echo so output is limited in DOS window.
  2. COLOR 70||                    :: Sets DOS window to default color schima.
  3. BREAK ON||                    :: Make sure you can use Ctrl-C key combo to break out of any batch file routene.
  4. REM ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5. REM :     File name: RemoveAltiris.cmd                                           :
  6. REM : Originated by: Chad Ellis                                                  :
  7. REM :----------------------------------------------------------------------------:
  8. REM :Current Author: XXXX XXXXXX As of XX/XX/XX until present                    :
  9. REM :----------------------------------------------------------------------------:
  10. REM :       DO NOT EDIT THIS FILE WITHOUT INFORMING THE CURRENT AUTHOR(S)        :
  11. REM :                             AS LISTED ABOVE                                :
  12. REM :----------------------------------------------------------------------------:
  13. REM :       Purpose: Remove SMA cleanly off all machines including Package       :
  14. REM :                Servers. (This does NOT remove any Deployment Server Agents):
  15. REM :     Frequency: ...                                                         :
  16. REM :    Invocation: ...                                                         :
  17. REM :     Arguments: ...                                                         :
  18. REM :      Switches: ...                                                         :
  19. REM : Special Logic: ...                                                         :
  20. REM : Special Notes: ...                                                         : 
  21. REM : File Location: ...                                                         :
  22. REM :  Color Schima: Use colors to better define window messages.                :
  23. REM :                     Install = Color 70          Default = Color 07         :
  24. REM :                InstallError = Color 74            Error = Color 0C         :
  25. REM :              InstallSuccess = Color 72          Success = Color 0A         :
  26. REM :              InstallMessage = Color 71          Message = Color 0F         :
  27. REM :              InstallWarning = Color 7E          Warning = Color 0E         :
  28. REM :----------------------------------------------------------------------------:
  29. REM : MMDDYY (ver x.x.x)    V E R S I O N    1 . 0 1         By Author Chad Ellis:
  30. REM :----------------------------------------------------------------------------:
  31. REM : 120506 Initial Release ...                                                 :
  32. REM : 110107 Added section that removes registry entry where Altiris is installed:
  33. REM :        This is needed or the re-install will fail because AeXNSC.exe checks: 
  34. REM :        to make sure Altiris is not already installed. If so, it skips the  :
  35. REM :        install process.                                                    :
  36. REM :      - Checks to see if you are an administrator before trying to remove   :
  37. REM :        the agent. Let's user know if they don't have enough rights.        :
  38. REM : 111307 Fixed cosmetic issue with detecting if Altiris was uninstall        :
  39. REM :        improperly.                                                      :
  40. REM : 121709 (v1.3) Replaced Altiris with Symantec Management Agent              :
  41. REM : 062110 (v1.4) Updated Altiris uninstall program as-well-as added a bunch of: 
  42. REM :        new commands to look for and remove NS v6 and v7 sub programs.      :
  43. REM : 062210 (v1.5) Forced AltirisAgentAutoDeploy and AT commands to stop forcing: 
  44. REM :        Altiris agent to install.                                           :
  45. REM : 070610 (v1.6) Rename pcAnywhere local directory if exist.                  :
  46. REM : 070710 (v1.7) Removed SMS Agent v7.0.1262.0, two more versions of pcA agent:
  47. REM : 070710 (v1.8) Force pcAnywhere and Altiris agent to close before renaming  :
  48. REM :        folders.                                                            :
  49. REM : 080310 (v1.9) Add CPU throttle to script. (Managed Solutions need it re-   :
  50. REM :        throttled.                                                          :
  51. REM : 081610 (v1.10) Net Stop any Altiris service and stops better pcA services  :
  52. REM :        before killing these services. Also, now supports Windows 2K OS.    :
  53. REM ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  54.  
  55.  
  56.  
  57. :: #------------------------------------------------------------------------#
  58. :: #----- BEGIN "Global Settings"                                      -----#
  59. SET SV=1.10||                                :: Set Script Version (SV) variable for Virtual Standardized Office (VSO)
  60. SET AltirisDir=C:\Program Files\Altiris\Altiris Agent||            :: Set default Altiris install folder just incase.
  61.  
  62.     :: #- Display the following message in the title bar.
  63. TITLE Remove Symantec Management Agents "Altiris Notification Server" agents (Script Version %SV%)|| :: Title given to this script file.
  64.  
  65.     :: #- Detect OS and set new variables to identify OS.
  66. SET Processor|FIND "64">NUL&&        SET BIT=64||        REM General 64 BIT OS
  67. VER|FIND /I "6001">NUL &&         SET OSVER=Vista64||    REM Operating system is Vista 64 bit.
  68. VER|FIND /I "6000">NUL &&         SET OSVER=Vista32||    REM Operating system is Vista 32 bit.
  69. VER|FIND /I "5.2">NUL &&        SET OSver=23||        REM Operating System is windows 2003
  70. VER|FIND /I "XP">NUL &&            SET OSver=XP||        REM Operating System is windows XP
  71. VER|FIND /I "Windows 2000">NUL &&    SET OSver=2K||        REM Operating System is Windows 2000
  72. VER|FIND /I "NT">NUL &&            SET OSver=NT||        REM Operating System is Windows NT 4.0
  73.  
  74.     :: #- Set Date variables for Day (spelled out), Month, Day (time), Year
  75. FOR /F "tokens=1,2,3,4 delims=/ " %%i IN ('DATE /T') DO (set Day=%%i&& set MM=%%j&& SET DD=%%k&& SET YY=%%l)
  76.  
  77.     :: #- Set time variables for Hr, Min, AM or PM
  78. FOR /F "tokens=1,2,3,4 delims=: " %%i IN ('Time /T') DO (set Hr=%%i&& set Min=%%j&& SET AMPM=%%k)
  79.  
  80.     :: #- If temp directory is not set, set it. If not, this batch file may fail.
  81. SET TempDir=%Temp%||                        :: Default temp directory of the OS.
  82. IF NOT EXIST "%Temp%" SET TempDir=%SystemDrive%\temp\apps||    :: If no temp directory exists, then set it.
  83. IF NOT EXIST "%TempDir%" MD "%TempDir%"||            :: Temp directory must exist or this script file may bomb out
  84.  
  85. CLS||                                :: Clear screen before continuing.
  86. GOTO Pre
  87. :: #----- END "Global Settings"                                        -----#
  88. :: #------------------------------------------------------------------------#
  89.  
  90.  
  91.  
  92. :: #------------------------------------------------------------------------#
  93. :: #----- BEGIN "Pre-Section"                                          -----#
  94. :Pre
  95.     :: #- Detect if Altiris is installed
  96.    ECHO Checking to see if Altiris is installed
  97.    REGv1 Query "HKLM\Software\Altiris\Altiris Agent\InstallDir" | FIND /I "Altiris" >NUL && ECHO Altiris is installed && FOR /F "tokens=2*" %%i IN ('REGv1 Query "HKLM\Software\Altiris\Altiris Agent\InstallDir"') DO (SET AltirisDir=%%j)|| ECHO Altiris is NOT installed
  98.    ECHO.
  99.     :: #- Check if user has enough rights to remove Symantec Management Agents.
  100.    NET SHARE 1>NUL 2> "%TempDir%\HaveAccess.tmp"
  101.    Type "%TempDir%\HaveAccess.tmp" | FIND /I "is denied" >NUL && GOTO AccessDenied
  102.  
  103. GOTO Main
  104. :: #----- END "Pre-Section"                                            -----#
  105. :: #------------------------------------------------------------------------#
  106.  
  107.  
  108.  
  109. :: #------------------------------------------------------------------------#
  110. :: #----- BEGIN "Main Section"                                         -----#
  111. :Main
  112.     :: #- Stop Altiris Services (speed up uninstall process)
  113.    NET STOP "Altiris Agent" /Y 2>NUL||            REM Stop NS v6 agent
  114.    NET STOP "Symantec Management Agent" /Y 2>NUL||        REM Stop NS v7 agent
  115.  
  116. :RemoveSubSolutions
  117.     :: Make sure all 7.x applications are removed before v6 apps.
  118.    ECHO ... checking for remaing Altiris v7.x sub programs and removing if found
  119.    CALL MsiExec.exe /X{D0ECC4C3-B181-4D08-B273-071A6F81C0E3} /QN &&     ECHO Removed "Altiris Application Metering Agent" v7.0.1104.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  120.    CALL MsiExec.exe /X{577BADC4-232D-4380-AEF8-552146B822FC} /QN &&    ECHO Removed "Altiris Application Metering Agent" v7.0.1218.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  121.    CALL MsiExec.exe /X{3FBC18B6-51A1-424A-BD1B-2F16C9ED6762} /QN &&    ECHO Removed "Altiris Application Metering Agent" v7.0.1255.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  122.    CALL MsiExec.exe /X{DB890B22-A001-4836-9344-874466EA7D0B} /QN &&    ECHO Removed "Altiris Inventory Agent" v7.0.1106.0            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  123.    CALL MsiExec.exe /X{300501b4-4a18-4cb9-96c4-da76d3e4a870} /QN &&    ECHO Removed "Altiris Inventory Agent" v7.0.1218.0            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  124.    CALL MsiExec.exe /X{FF8CACB4-A06D-4DE5-B5DB-2C565F36C496} /QN &&    ECHO Removed "Altiris Inventory Agent" v7.0.1255.0            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  125.    CALL MsiExec.exe /X{16ABB89C-5D2D-47BE-B76B-0D283F55C9F0} /QN &&    ECHO Removed "Altiris Inventory Pack for Servers Agent" v7.0.1041.0    && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  126.    CALL MsiExec.exe /X{4DE27314-B129-49E6-A806-6F38548A7A01} /QN &&    ECHO Removed "Altiris Inventory Pack for Servers Agent" v7.0.1212.0    && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  127.    CALL MsiExec.exe /X{8AFCD465-3701-4BAB-9699-99CF4BC859B2} /QN &&    ECHO Removed "Altiris Inventory Pack for Servers Agent" v7.0.1255.0    && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  128.    CALL MsiExec.exe /X{B3D3F590-3B95-4A39-87D9-FFCD0C5EB6EA} /QN &&    ECHO Removed "Altiris Power Scheme Agent" v7.0.1218            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  129.    CALL MsiExec.exe /X{00293E7E-A756-42B3-A555-202D352A3021} /QN &&    ECHO Removed "Dell Client Manager Agent" v2.2.1019            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  130.    CALL MsiExec.exe /X{20ECE555-DE4B-4CB1-A2C3-EBBF811A2F44} /QN &&    ECHO Removed "Dell Client Manager Agent" v3.1.1128            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  131.    CALL MsiExec.exe /X{3E4FE54C-F756-4A39-BC76-CC08A6944D0D} /QN &&    ECHO Removed "Dell Client Manager Agent" v3.1.1230            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  132.    CALL MsiExec.exe /X{002E1E2C-FA5B-4F26-9889-07B51D2D62EF} /QN &&    ECHO Removed "Deployment Solution Agent" v7.1.561.0            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  133.    CALL MsiExec.exe /X{4E0B7E45-19CF-4DB0-96C6-1FB5B040E2C0} /QN &&    ECHO Removed "Patch Management Agent" v7.0.3308.0            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  134.    CALL MsiExec.exe /X{A2935B63-651C-434C-B954-D7BFE3CCD8B5} /QN &&    ECHO Removed "Patch Management Agent" v7.0.4071.0            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  135.    CALL MsiExec.exe /X{7938CF43-01F9-4F81-BB42-2BF1875AA403} /QN &&    ECHO Removed "Patch Management Agent" v7.0.4210.0            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  136.    CALL MsiExec.exe /X{D2D185EF-E6A8-4FB6-B967-B37C31C33245} /QN &&    ECHO Removed "Out of Band Management Agent" v7.0.1286            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  137.    CALL MsiExec.exe /X{75B46292-E8CB-494e-A374-8FBAD4856AE2} /QN &&    ECHO Removed "Software Management Solution Agent" v7.0.1262.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  138.    CALL MsiExec.exe /X{CEB4EE28-1A87-478A-BEBC-EFFB987C9F2C} /QN &&    ECHO Removed "Software Management Solution Agent" v7.0.1492.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  139.    CALL MsiExec.exe /X{B5AC4CBA-6127-4089-9769-8B5A781DB6DB} /QN &&    ECHO Removed "Software Management Solution Agent" v7.0.1698.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  140.    CALL MsiExec.exe /X{0b8f76cc-1880-4e1e-acb3-8de63cedd549} /QN &&    ECHO Removed "Software Management Solution Agent" v7.0.1831.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  141.    CALL MsiExec.exe /X{32DE07AD-308A-484B-8BFE-740D8F9C80EB} /QN &&    ECHO Removed "Symantec_pcAnywhere_plugin_installer" v12.5.177.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  142.    CALL MsiExec.exe /X{BD52ED7E-9843-45E6-99E8-7C5F79A1AAF9} /QN &&    ECHO Removed "Symantec_pcAnywhere_plugin_installer" v12.5.177.0        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  143.    CALL MsiExec.exe /X{125E8183-866A-11D3-97DF-0000F8D8F2E9} /QN &&    ECHO Removed "Symantec pcAnywhere" v12.5.0.618                && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  144.    CALL MsiExec.exe /X{CEF8B562-5070-4E06-B81C-47FA4718C83A} /QN &&    ECHO Removed  "WinPE_2.1" v7.1.598.0                    && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  145.  
  146.  
  147.     :: Start removing 6.x applications individually.
  148.    ECHO ... checking for remaing Altiris v6.x sub programs and removing if found
  149.    CALL MsiExec.exe /X{4A702DA1-9E48-4346-8030-26B399CCFA8C} /QN &&    ECHO Removed "Altiris Application Metering Agent" v6.1.x        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  150.    CALL MsiExec.exe /X{332454D8-73B0-4b4a-954C-D96089CD898A} /QN &&    ECHO Removed "Carbon Copy" v6.2.x                    && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  151.    CALL MsiExec.exe /X{C305C005-290B-4A5B-BA11-C6E4F587D67C} /QN &&    ECHO Removed "Altiris Diagnostics" v6.1.7631.0                && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  152.    CALL MsiExec.exe /X{8970C168-CA49-4D52-A913-7E7E1CB261F0} /QN &&    ECHO Removed "Altiris Diagnostics" v6.1.7330.0                && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  153.    CALL MsiExec.exe /X{A847BFFB-A77E-4D71-A22F-6268EAF1B1AB} /QN &&    ECHO Removed "Altiris Patch Management Agent" v6.1.1430            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  154.    CALL MsiExec.exe /X{B74681B8-CCE9-4681-BADF-CFEE340227A3} /QN &&    ECHO Removed "Altiris Patch Management Agent" v6.0.1137            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  155.    CALL MsiExec.exe /X{A0A1EB01-A6FD-423A-8480-364055A7C961} /QN &&    ECHO Removed "Altiris Software Delivery Solution Agent"            && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  156.    CALL MsiExec.exe /X{2851123E-5786-41BE-A3F1-A9B21E499EEB} /QN &&    ECHO Removed "Altiris Task Synchronization Agent" v6.1.1x        && SET Wait=Yes && START /MIN ThrottleCPU.cmd
  157.  
  158. :RemovepcAnywhere
  159.        :: #- Default settings for pcAnywhere
  160.    SET pcAGUID=12518183-866A-11D3-97DF-0000F8D8F2E9||            :: Latest pcA agent GUID
  161.    SET pcANSGUID=125E8183-866A-11D3-97DF-0000F8D8F2E9||            :: Latest pcA agent GUID for NS v7 Solution
  162.    SET pcAInstallDir=C:\Program Files\Symantec\pcAnywhere||        :: Default location where pcA is installed. (This is set just incase the registry portion was removed but folders still exist locally. Current value doesn't work with 64-bit systems.)
  163.    SET pcAInstallDir64=C:\Program Files (x86)\Symantec\pcAnywhere||    :: Default location where pcA is instaleld on 64-bit systems.
  164.  
  165.     :: #- Set default location where pcAnywhere host files exist
  166.    VER|FIND /I "Version 6" && SET AppData=&&                :: Re-set AppData variables if computer is Vista.
  167.    SET pcASettingsDir=%AllUsersProfile%\Application Data\Symantec\pcAnywhere||    :: Default location where pcA data is located
  168.    SET HostDir=%pcASettingsDir%\Hosts||                    :: Set default location of Host folder
  169.  
  170.     :: #- Set default location where pcAnywhere "Remotes" folder exists
  171.    SET RemoteDir=%pcASettingsDir%\Remotes||                :: Detfault folder for Remotes location
  172.  
  173.     :: #- Directory where pcAnywhere is installed (Set %pcAInstallDir%)
  174.    FOR /F "tokens=2*" %%i IN ('REGv1 QUERY "HKLM\SOFTWARE\Symantec\pcAnywhere\CurrentVersion\System\InstallDir"') DO (SET pcAInstallDirTest=%%j)
  175.    IF EXIST "%pcAInstallDirTest%" SET pcAInstallDir=%pcAInstallDirTest%||    :: Re-set pcAInstallDir if directory exist as detailed in registry, else use old setting.
  176.  
  177.     :: #- Backup pcA "Remotes" folder
  178.    ECHO Checking for pcAnywhere and removing it.
  179.    IF EXIST "%RemoteDir%" (ROBOCOPY "%RemoteDir%" "%TempDir%\pcA\Remotes" /MIR /Z >NUL & ECHO ... pcA "Remotes" computers found& EchO ... Backed up "Remote" computers/configurations)
  180.  
  181.     :: #- Backup NS v7 Solution "pcANSHost.bhf" file.
  182.    IF EXIST "%HostDir%\pcANSHost.bhf" (ROBOCOPY "%HostDir%" "%TempDir%\pcA\NSHosts" *.* >NUL & ECHO ... pcA Host file backed up. & SET BHF=pcaNSHost.bhf)
  183.    FOR /F "tokens=2*" %%i IN ('REGv1 QUERY HKLM\SOFTWARE\Symantec\pcAnywhere\CurrentVersion\Host\autostart') DO (SET FullBHFPathpcaNSHost=%%j)
  184.    ECHO.
  185.     
  186.     :: #- Stop pcA Services
  187.    IF EXIST "%pcAInstallDir%\STOPHOST.exe" ECHO Stopping pcAnywhere Services && CALL "%pcAInstallDir%\STOPHOST.exe" 2>NUL && ECHO ... Stopped! && TIMEOUT 5
  188.    IF EXIST "%pcAInstallDir%\KILLHOST.exe" cALL "%pcAInstallDir%\KILLHOST.exe" 2>NUL && TIMEOUT 5
  189.  
  190.     :: #- Uninstall pcAnywhere v12.5 (NS Solution/trialware)
  191.    ECHO Checking if "Notification Server Solution" or "trialware" version of pcAnywhere v12.5 is installed
  192.    REGv1 QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{%pcANSGUID%}>NUL&& CALL MsiExec.exe /X{%pcANSGUID%} /qb >NUL && timeout 120 && ECHO ... pcAnywhere v12.5 NS Solutions version was removed!|| ECHO ... pcAnywhere v12.5 not installed.
  193.    ECHO.
  194.  
  195.     :: #- Uninstall pcAnywhere v12.5 (Licensed Version)
  196.    ECHO Checking if "licensed version" of pcAnywhere v12.5 is installed
  197.    REGv1 QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{%pcAGUID%}>NUL&& CALL MsiExec.exe /X{%pcAGUID%} /qb >NUL && TIMEOUT 120 && ECHO ... Removed pcAnywhere "boxed" version || ECHO ... pcAnywhere v12.5 not installed.
  198.    ECHO.
  199.  
  200. :RemoveCarbonCopy
  201.     :: Double check and force Carbon Copy to be removed
  202.    ECHO ... Forcing Carbon Copy to uninstall (Extra precaution)
  203.    CALL CarbonCopyScrub_NoReboot.exe
  204.    ECHO ... removal of Carbon Copy is complete
  205.    ECHO.
  206.  
  207. :RemoveNSAgent
  208.     :: #- Remove Symantec Management Agents 1st
  209.    IF "%Wait%"=="Yes" (ECHO Altiris sub agents are uninstalling, please wait until they finish && TIMEOUT 60 && ECHO.)
  210.    ECHO Removing "main" Symantec Management Agents (Altiris "Notification Server" agents)
  211.    CALL AeXNSClientUninstall.exe && ECHO Please wait while "main" Altiris agent is uninstalled && TIMEOUT 30 
  212.  
  213.     :: #- Double check to make sure agent is gone.
  214.    IF EXIST "%AltirisDir%\AeXNSAgent.exe" (CALL "%AltirisDir%\AeXNSAgent.exe" /uninstall)||    :: Remove "Altiris Agent" v6.1.x
  215.    IF EXIST "C:\Program Files\Altiris\Altiris Agent\AeXNSAgent.exe" (CALL  "C:\Program Files\Altiris\Altiris Agent\AeXNSAgent.exe" /uninstall)
  216.  
  217. :RemoveShares
  218.      :: #- Cleanup uninstall - delete any shares that are still active.
  219.    ECHO.
  220.    ECHO Making sure Symantec Management Agents were uninstalled correctly.
  221.    ECHO    ... Checking / deleting any remaining hidden shares
  222.    FOR /F "tokens=1*" %%i in ('NET SHARE ^| FIND /I "PkgSvrHost"') DO (NET SHARE %%i "%%j" /DELETE /Y)
  223.  
  224.     :: #- Double Checking to make sure shares are gone
  225.    NET SHARE | FIND /I "PkgSvrHost" && Color 74 && ECHO    ... hidden shares from Package Server did NOT remove! ^:-( && ECHO Make sure you have administrative rights to the folder where Symantec Management Agents are installed && ECHO Then re-run the Symantec Management uninstall program again. && Timeout 30 && COLOR 70 || ECHO    ... verified - no hidden shares from Package Server exist.
  226.  
  227. :RemoveAltirisAgentAutoDeploy
  228.     :: #- Force the removal of AltirisAgentAutoDeploy
  229. rem   CALL MsiExec.exe /X{DAB76F40-BE93-481A-8ED4-B983F78BB798} /QN &&    ECHO Removed "Altiris Agent Auto Deploy" v2.0.1||    :: "remmed" this section out because we think if it remains in Add/Remove, the GPO won't try to re-install it.
  230.  
  231.     :: #- Remove all incidents of FullInstall.vbs from AT command
  232.    FOR /F %%i IN ('AT ^| Find /i "FullInstall.vbs"') DO (AT %%i /Delete /Yes)
  233.  
  234.     :: #- Remove FullInstall.vbs from local drive
  235.    IF EXIST "C:\Program Files\Jacobs\AltirisAgentAutoDeploy\fullinstall.vbs" (PUSHD C:\Program Files\Jacobs\AltirisAgentAutoDeploy >NUL && DEL *.* /F /Q >NUL && POPD)
  236.    IF EXIST "C:\Program Files\Jacobs\AltirisAgentAutoDeploy" RMDIR "C:\Program Files\Jacobs\AltirisAgentAutoDeploy" /Q
  237.  
  238. :PatchIssues
  239.     :: #- If Patch Management components are installed and agent has been re-installed to new location errors happen. Search and remove the issue so "Software Updates" tab will re-install correctly in the agent.
  240.    REGv1 QUERY "HKLM\SOFTWARE\Classes\Installer\Products\BFFB748AE77A17D42AF22686AE1F1BBA">NUL && ECHO   ... Fixing Registry so "Software Updates" tab shows up in Symantec Management agent area. && REGv1 DELETE "HKLM\SOFTWARE\Classes\Installer\Products\BFFB748AE77A17D42AF22686AE1F1BBA" /FORCE
  241.    REGv1 QUERY "HKLM\SOFTWARE\Altiris\Altiris Agent\SW Inventory Agent\MsiInventory\Policies\9B81B317-D0CC-4D3C-A82E-E36E8939562B" >NUL && ECHO   ... Fixing Registry so "Software Updates" tab shows up in Symantec Management Agent area. && REGv1 DELETE "HKLM\SOFTWARE\Altiris\Altiris Agent\SW Inventory Agent\MsiInventory\Policies\9B81B317-D0CC-4D3C-A82E-E36E8939562B" /FORCE
  242.  
  243.     :: #- Check to see if Symantec Management Agents were removed correctly
  244.    ECHO.
  245.    ECHO Checking to see if Symantec Management Agents were removed correctly.
  246.    FOR /F "tokens=2* " %%i IN ('REGv1 QUERY "HKLM\SOFTWARE\ALTIRIS\eXpress\NS Client" ^| FIND /i "InstallDir"') DO (SET InstallDir=%%j)
  247.  
  248.     :: #- If InstallDir exists then SMA failed to uninstalled correctly. (Remove section in registry that makes new installs fail.)
  249.    REGv1 QUERY "HKLM\SOFTWARE\ALTIRIS\eXpress\NS Client\Version" >NUL && GOTO CleanupRegistry || ECHO    ... Symantec Management Agents have been successfully removed.
  250. GOTO POST
  251.  
  252. :CleanupRegistry
  253.     :: #- Let user know Symantec Management Agents did not uninstall correctly. (That you are fixing it.)
  254.    ECHO. 
  255.    ECHO     !!! Symantec Management Agents are having issues uninstalling !!!
  256.    ECHO.
  257.    ECHO Please stand by as secondary uninstall tool fixes issue.
  258.  
  259.     :: #- Remove section in Registry that make SMA think the client is installed.
  260.    REGv1 DELETE "HKLM\SOFTWARE\ALTIRIS\eXpress\NS Client\Version" /FORCE >NUL && ECHO    ... Fixed uninstall issue #1
  261.    ECHO Finished resolving common uninstall issues!
  262.    ECHO.
  263. GOTO Post
  264. :: #----- END "Main Section"                                           -----#
  265. :: #------------------------------------------------------------------------#
  266.  
  267.  
  268.  
  269. :: #------------------------------------------------------------------------#
  270. :: #----- BEGIN "Post Section"                                         -----#
  271. :Post
  272.     :: #- Cleanup Registry for v6 Altiris agent if exist.
  273.    ECHO.
  274.    ECHO Checking to see if Altiris exists in registry
  275.    REGv1 DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{92F2A534-C3E4-4B18-BEBD-329F5E848C8B}" /Force > NUL && ECHO ... Removed from registry
  276.  
  277.     :: #- Give more time to remove applications before moving on.
  278.    ECHO Waiting for Application to finish uninstall
  279.    TIMEOUT 60
  280.  
  281.     :: #- Check to see if pcAnyhere is running. If so, kill it before renaming folder.
  282.    IF EXIST "%pcAInstallDir%\STOPHOST.exe" ECHO Stopping pcAnywhere Services && CALL "%pcAInstallDir%\STOPHOST.exe" 2>NUL && ECHO ... Stopped! && TIMEOUT 5
  283.    IF EXIST "%pcAInstallDir%\KILLHOST.exe" cALL "%pcAInstallDir%\KILLHOST.exe" 2>NUL && TIMEOUT 5
  284.                    FOR /F "tokens=2 " %%i IN ('PSLIST ^| FIND /I "pcA"') DO (KILL -F %%i)
  285.    IF NOT "%OSver%"=="2K"     FOR /F "tokens=2 " %%i IN ('TaskList ^| FIND /I "pcA"') DO (KILL -F %%i)
  286.  
  287.     :: #- Rename local pcAnywhere install directory
  288.    IF EXIST "%pcAInstallDir%" (ECHO ... Renaming "%pcAInstallDir%" to "pcAnywhere_%Day% %MM%-%DD%-%YY% %HR%.%Min% %AMPM%" && RENAME "%pcAInstallDir%" "pcAnywhere_%Day% %MM%-%DD%-%YY% %HR%.%Min% %AMPM%" && ECHO Renamed Successfully! && ECHO.)|| ECHO ... Please wait for countdown to finish && TIMEOUT 60 && RENAME "%pcAInstallDir%" "pcAnywhere_%Day% %MM%-%DD%-%YY% %HR%.%Min% %AMPM%" && ECHO Renamed Successfully! && ECHO.)
  289.    IF EXIST "%pcAInstallDir64%" (ECHO ... Renaming "%pcAInstallDir64%" to "pcAnywhere_%Day% %MM%-%DD%-%YY% %HR%.%Min% %AMPM%" && RENAME "%pcAInstallDir64%" "pcAnywhere_%Day% %MM%-%DD%-%YY% %HR%.%Min% %AMPM%" && ECHO Renamed Successfully! && ECHO.)|| ECHO ... Please wait for countdown to finish && TIMEOUT 60 && RENAME "%pcAInstallDir64%" "pcAnywhere_%Day% %MM%-%DD%-%YY% %HR%.%Min% %AMPM%" && ECHO Renamed Successfully! && ECHO.)
  290.  
  291.     :: #- Check to see if Altiris is still running before renaming folder. If exist, stop it or kill it. (Use both PSLIST and TaskList commands to find ID number of anything running that has AeX.)
  292.    NET STOP "Altiris Agent" /Y 2>NUL||            REM Stop NS v6 agent
  293.    NET STOP "Symantec Management Agent" /Y 2>NUL||        REM Stop NS v7 agent
  294.                    FOR /F "tokens=2 " %%i IN ('PSLIST ^| FIND /I "AeX"') DO (KILL -F %%i)
  295.    IF NOT "%OSver%"=="2K"     FOR /F "tokens=2 " %%i IN ('TaskList ^| FIND /I "AeX"') DO (KILL -F %%i)
  296.  
  297.     :: Rename local Altiris folder before installing.
  298.    IF EXIST "%AltirisDir%" (ECHO ... Renaming "%AltirisDir%" to "Altiris Agent_%Day% %MM%-%DD%-%YY% %HR%.%Min% %AMPM%" && RENAME "%AltirisDir%" "Altiris Agent_%Day%%MM%-%DD%-%YY% %HR%-%Min% %AMPM%" && ECHO Renamed Successfully! && ECHO.)|| ECHO ... Please wait for countdown to finish && TIMEOUT 60 && RENAME "%AltirisDir%" "Altiris Agent_%Day%%MM%-%DD%-%YY% %HR%-%Min% %AMPM%" && ECHO Renamed Successfully! && ECHO.
  299. GOTO End
  300. :: #----- END "Post Section"                                           -----#
  301. :: #------------------------------------------------------------------------#
  302.  
  303.  
  304.  
  305. :: #------------------------------------------------------------------------#
  306. :: #----- BEGIN "Error messages"                                       -----#
  307. :AccessDenied
  308.    Color 74
  309.    CLS
  310.    ECHO   ╔════════╗═══════════════════════════════════════════════════════════════╗
  311.    ECHO   ║ ERROR  ║                       Access Denied                           ║
  312.    ECHO   ╚════════╝═══════════════════════════════════════════════════════════════╝
  313.    ECHO      You do not have enough rights to uninstall Symantec Management agents
  314.    ECHO.
  315.    ECHO         Please log in with Administrative or system rights to continue.
  316.    ECHO.
  317.    ECHO Exiting program!
  318.    TIMEOUT 60
  319. EXIT
  320. :: #----- END "Erorr Messages"                                         -----#
  321. :: #------------------------------------------------------------------------#
  322.  
  323.  
  324.  
  325. :End
  326. Color 72||                        :: Change screen color to represent a successful uninstall 
  327. ECHO Uninstall of Symantec Management Agents are complete.
  328. TIMEOUT 15
  329. GOTO :EOF||                            :: Exit batch file and make sure it only runs once.
  330.