SMS 2003 - Script per rimuovere in automatico da remoto il client SMS

Utile script per rimuovere dal proprio pc il client SMS su una postazione remota.

Facilmente adattabile per altre esigenze


'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.0
'
' NAME: SMSUninstall.vbs
'
' AUTHOR: Fellows, Richard
' DATE  : 7/1/2005
'
' COMMENT: Script to call the uninstall method for a specific application
'via Windows Installer and WMI
'
'==========================================================================
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = InputBox("Uninstall SMS on what computer?","SMS 2003 Remote deinstall",".")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery("Select * from Win32_Product Where Name = 'SMS Advanced Client'")
strfound = false
For Each objSoftware in colSoftware
        strfound = true
        Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
        strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & objSoftware.IdentifyingNumber
        strValueName = "NoRemove"
        dwValue = 0
        oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
            If Err <> 0 Then
                'Unable to set/find the NoRemove registry value for the SMS Advanced
Client
                        wscript.Echo "Error setting NoRemove value on: " & strKeyPath & " ErrorNumber: " & Err.Number & " Desciption: " & Err.Description
                Else
                        'found the SMS Advanced Client remove it!
                        objSoftware.Uninstall()
                        wscript.echo "Uninstall Started"
                End If
Next
If strfound = False Then
        WScript.Echo "Unable to locate the SMS advanced client on " & strComputer & "!"
end if
'==========================================================================
' End of Script
'==========================================================================