供应商/发布商卸载 Powershell

问题描述

我正在尝试全面卸载 Autodesk 的各种卸载程序。使用 wmic 我能够通过以下方式获得大部分卸载:

wmic product where "name like 'auto%%'" call uninstall

但是仍然安装了一堆应用程序。然后我尝试使用 powershell 并达到了可以找到剩余安装的程度:

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object displayname,UninstallString | Format-Table -AutoSize | findstr Autodesk

但是我对如何运行找到的每个卸载字符串感到困惑。除了 Autodesk,我想弄清楚这一点,以便我将来可以全面卸载其他供应商的安装,而不仅仅是通过应用程序名称

解决方法

您可以先尝试以下:

$UninstallApps = Get-WmiObject Win32_Product | Where-Object {$_.Name -like '*Application1*' -or $_.Name -like '*Application2*'}

$UninstallApps.Uninstall()

然后对于 HKLM 下的任何内容,您可以尝试执行以下操作:

$UninstallPaths = @( 
    'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') 

$UninstallSearchFilter = {$_.GetValue('DisplayName') -like 'Auto*'} 
 
Foreach ($Path in $UninstallPaths) { 
    if (Test-Path $Path) { 
        Get-ChildItem $Path | Where $UninstallSearchFilter |  
        Foreach { Start-Process 'C:\Windows\System32\msiexec.exe' "/x $($_.PSChildName) /qn" -Wait} 
    } 
}