Login to participate
Endpoint Management & Virtualization DownloadsRSS

Script to Uninstall ACLIENT from the Machine [Uninstall & Cleanup Script]

Eshwar's picture

Here is my script to uninstall ACLIENT from the machine. The script will uninstall using uninstall command and cleans up registry, files and folders which are remaining after the uninstall. Change the script according to your requirements. Good luck.

'DECLARE VARIABLES
'On Error Resume Next
Dim path

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

Set shell = CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
Set env = shell.Environment("Process")
Systemdrive = env.Item("Systemdrive")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
   strComputer & "\root\default:StdRegProv")
'===========================================================
'CHANGE THE PATH OF THE EXE ACCORDING TO YOUR REQUIREMENT
path = Chr(34) & "C:\altiris\aclient\aclient.exe" & Chr(34) & " /remove /silent"
'===========================================================
'shell.Run(path, 1, true)

'WScript.Sleep 30000

'=======================================================================
'FIND AND DELETE FILES
'=======================================================================
If fso.FileExists (Systemdrive & "\aclient.cfg") Then
 fso.DeleteFile (Systemdrive & "\aclient.cfg"), true
End If
If fso.FileExists (Systemdrive & "\WINDOWS\System32\drivers\AlKernel.sys") Then
 fso.DeleteFile Systemdrive & "\WINDOWS\System32\drivers\AlKernel.sys", true
End If
If fso.FileExists (Systemdrive & "\WIndows\Temp\alsmb.exe") Then
 fso.DeleteFile Systemdrive & "\Windows\Temp\alsmb.exe", True
End If
If fso.FolderExists (Systemdrive & "\Altiris\AClient") Then
 fso.DeleteFolder Systemdrive & "\Altiris\AClient", true
End If
If fso.FolderExists (Systemdrive & "\altiris") Then
 fso.DeleteFolder Systemdrive & "\Altiris", True
End If
'=======================================================================

'=======================================================================
'FIND AND DELETE REGISTRY KEYS
'=======================================================================
strKeyPath = "SYSTEM\CurrentControlSet\Enum\Root\LEGACY_ACLIENT"
oReg.EnumValues HKEY_LOCAL_MACHINE,strKeyPath,arrValueNames, arrValueTypes
If IsNull(arrValueNames) Then 
     'Wscript.Echo "The registry key does not exist!"
Else
 'Wscript.Echo "The registry key exists!"
 shell.RegDelete "HKLM\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_ACLIENT\"
End If

strKeyPath = "SYSTEM\ControlSet001\Enum\Root\LEGACY_ACLIENT"
oReg.EnumValues HKEY_LOCAL_MACHINE,strKeyPath,arrValueNames, arrValueTypes
If IsNull(arrValueNames) Then 
     'Wscript.Echo "The registry key does not exist!"
Else
 'Wscript.Echo "The registry key exists!"
 shell.RegDelete "HKLM\SYSTEM\ControlSet001\Enum\Root\LEGACY_ACLIENT\"
End If

strKeyPath = "SYSTEM\ControlSet001\Services\AClient"
oReg.EnumValues HKEY_LOCAL_MACHINE,strKeyPath,arrValueNames, arrValueTypes
If IsNull(arrValueNames) Then 
     'Wscript.Echo "The registry key does not exist!"
Else
 'Wscript.Echo "The registry key exists!"
 shell.RegDelete "HKLM\SYSTEM\ControlSet001\Services\AClient\"
End If

'shell.RegDelete "HKLM\SYSTEM\CurrentControlSet\Enum\Root\LEGACY_ACLIENT\"
'shell.RegDelete "HKLM\SYSTEM\ControlSet001\Enum\Root\LEGACY_ACLIENT\"
'shell.RegDelete "HKLM\SYSTEM\ControlSet001\Services\AClient\"
'=======================================================================

strKeyPath = "SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List"
strStringValueName = "C:\Program Files\Altiris\AClient\AClntUsr.EXE"
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName

strKeyPath = "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List"
strStringValueName = "C:\Program Files\Altiris\AClient\AClntUsr.EXE"
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName

shell.LogEvent 0, "Successfully removed aclient"

Set shell = Nothing
Set fso = Nothing

WScript.Quit

Otkripkin's picture

(No subject)

aspen's picture

Check the code

This does not work in all circumstances in particular your script will fail on folders with read-only attributes. Adding a function to remove read-only attributes if they are encountered is a smart move. You need to think about including logging and on error resume statements so that you can ininstall broken installations.