我尝试使用 VBScript 卸载已安装在我的系统中的 Windows 应用程序 exe。但是无法卸载exe。请帮助我。提前致谢。
我尝试使用以下代码:
Dim oReg, oShell, oFSO
Dim UninstallString, ProductCode
Dim strComputer, colItems, objWMIService, objItem
Dim strKeyPath, subkey, arrSubKeys
strComputer = "."
'********************************
'Enter Product Code Of The Application Here That You Want To Uninstall within the Bracket
ProductCode = "{XXXXC6BA-0F96-4E3B-BB14-211E2805XXXX}"
'********************************
' Get scripting objects needed throughout script.
Set oShell = CreateObject("WScript.Shell")
'**************************
UninstallString = "Database Upgrade Utility.exe /X" & ProductCode & " /qn" & " /norestart"
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
IF subkey = ProductCode Then
oShell.Run UninstallString, 1, True
End If
Next
Set oShell = Nothing
Set oReg = Nothing
修改后的代码
Dim oReg, oShell, oFSO
Dim UninstallString, ProductCode
Dim strComputer, colItems, objWMIService, objItem
Dim strKeyPath, subkey, arrSubKeys
strComputer = "."
'********************************
'Enter Product Code Of The Application Here That You Want To Uninstall within the Bracket
ProductCode = "{4AE9C6BA-0F96-4E3B-BB14-211E2805227E}"
'********************************
' Get scripting objects needed throughout script.
Set oShell = CreateObject("WScript.Shell")
'**************************
UninstallString = """C:\Program Files\ASCO\DatabaseUpgradeUtility\ASCO Database Upgrade Utility.exe"" /X" & ProductCode & " /qn /norestart"
'UninstallString = "ASCO Database Upgrade Utility.exe /X" & ProductCode & " /qn" & " /norestart"
InputBox(UninstallString)
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
'IF subkey = ProductCode Then
'.Run UninstallString, 1, True
'End If
IF subkey = ProductCode Then
oShell.Run "%COMSPEC% /k " & UninstallString, 1, True
End If
Next
Set oShell = Nothing
Set oReg = Nothing
尝试了上述方法,路径也没有双引号,但两者都不起作用。如果我必须在上面的脚本中更改任何内容,请提供给我。