我已经工作了几天了,不管我如何运行它,它似乎都会通过PowerShell卸载程序,并返回成功代码:
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
PSComputerName :这发生在各种出了名的难以删除的软件上,比如McAfee。
正在使用的命令是:
Get-WmiObject -Class win32_product -Filter "Name like '%McAfee%'" | ForEach-Object {$_.Uninstall()}我在这里尝试了各种脚本、解决方案以及它们的变体(如下所示)。
$uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "Yahoo Messenger" } | select UninstallString
$uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "Yahoo Messenger" } | select UninstallString
if ($uninstall64) {
$uninstall64 = $uninstall64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall64 = $uninstall64.Trim()
Write "Uninstalling (x64)..."
start-process "msiexec.exe" -arg "/X $uninstall64 /qb" -Wait
}
if ($uninstall32) {
$uninstall32 = $uninstall32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall32 = $uninstall32.Trim()
Write "Uninstalling (x32)..."
start-process "msiexec.exe" -arg "/X $uninstall32 /qb" -Wait}即使是Yahoo Messenger这样的简单命令,以Administrator身份从Powershell窗口运行时也无法卸载应用程序,但会返回成功代码和/或不再出现在WMI应用程序列表中。
发布于 2018-02-15 08:26:50
您可以检查MSIInstaller事件以查找卸载失败的原因:
Get-WinEvent -computername <computername> -ProviderName MSIInstaller -Maxevents 30您还可以使用添加到msiexec.exe调用中的/le '<logfilepath>'来记录MSI活动,并检查结果。
我相信msi安装/卸载操作是异步的。您可能需要在pssession中等待,直到安装完成。
McAfee代理有时需要删除frminst.exe /forceuninsall。
https://stackoverflow.com/questions/48798158
复制相似问题