• LOGIN
  • Nenhum produto no carrinho.

Script – Removendo aplicações por VBS

Olá pessoal,
 
Segue uma dica de como utilizar um script (VBS) para remover uma aplicação.

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = “.”
Set oShell = WScript.CreateObject(“WScript.Shell”)
Set StdOut = WScript.StdOut
Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & strComputer & “rootdefault:StdRegProv”)
strKeyPath = “SoftwareMicrosoftWindowsCurrentVersionUninstall”
err.Clear
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
If err.Number <> 0 Then
StdOut.WriteLine strKeyPath & ” is not a valid registry key path.”
WScript.Quit
End If
For Each subkey In arrSubKeys
strSubKeyPath = strKeyPath & “” & subkey
oReg.EnumValues HKEY_LOCAL_MACHINE, strSubKeyPath, arrValueNames, arrValueTypes
If IsArray(arrValueNames) Then
For Each strValue In arrValueNames
If strValue = “DisplayName” Then
err.Clear
GetValueStatus = oReg.GetExpandedStringValue(HKEY_LOCAL_MACHINE, strSubKeyPath, strValue, strDisplayName)
If (GetValueStatus <> 0) and (err.Number <> 0) Then
StdOut.WriteLine “Key Name: ” & subkey
StdOut.WriteLine ” Error retrieving value data.”
Else
If (InStr(1, strDisplayName, “Microsoft Online Services Sign-in Assistant“, 1) <> 0) AND (InStr(1, strDisplayName, “Microsoft Online Services Sign-in Assistant“, 1) <> 0) Then
StdOut.WriteLine “Key Name: ” & subkey
StdOut.WriteLine ” Application Name: ” & strDisplayName
GetValueStatus = oReg.GetExpandedStringValue _
(HKEY_LOCAL_MACHINE, strSubKeyPath, “DisplayVersion” , strDisplayVersion)
arrAppVersion = Split(strDisplayVersion, “.”)
If arrAppVersion(0) < 8 Then
GetValueStatus = oReg.GetExpandedStringValue _
(HKEY_LOCAL_MACHINE, strSubKeyPath, “UninstallString” , strUninstallString)
If InStr(1, strUninstallString, “msiexec”, 1) <> 0 Then
If InStr(1, strUninstallString, “/I”, 1) <> 0 Then
strUninstallString = Replace(strUninstallString, “/I”, “/X”)
End If
If InStr(1, strUninstallString, “/q”, 1) = 0 Then
strUninstallString = strUninstallString & ” /qn”
End If
If InStr(1, strUninstallString, “restart”, 1) = 0 Then
strUninstallString = strUninstallString & ” /norestart”
End If
End If
StdOut.WriteLine ” Uninstall String: ” & strUninstallString
oShell.Run strUninstallString, 1, True
Else
StdOut.WriteLine ” Current Version Installed.”
End If
End If
End If
End If
Next
End If
Next
 
Microsoft Online Services Sign-in Assistant = Nome do aplicativo para ser removido.
 
Até a próxima,
 
Marco Antonio (Mada)

05/08/2014
WB - Todos os direitos reservados
X