我試圖卸載已安裝在我的系統中使用VBScript的Windows應用程序EXE。但是無法卸載exe。請幫助我。提前致謝。VBScript卸載Windows應用程序
我試着用下面的代碼:
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
試過以上和路徑也與TRID了雙引號也但兩者都沒有工作。如果有任何需要更改上述腳本的內容,請提供給我。
'... 「數據庫升級Utility.exe/X」 ...'看起來像是乞求各地的可執行文件的名字報價。 – cHao
「不工作」是一個不充分的問題描述。如何* execatly *是「不工作」?你在'CMD'窗口中得到了什麼輸出?命令的返回值是多少?你是否確認它正在運行? –