【发布时间】:2022-09-27 21:22:38
【问题描述】:
是否有一条通用线路可以删除/卸载控制面板中显示的任何应用程序? 最好是 PowerShell,但可以是另一种语言。 我有删除 .msi 而不是 .EXE 的行。 这部分非常困难,我不了解 .EXE 和 .MSI 之间的区别,如果有人知道如何区分它们,那么我至少可以解决 .msi
这是我为 .msi 设置的代码
$ComputerName = Read-Host -Prompt \'Input the computer name\' # the name of the computer to remove the app from
Get-WmiObject Win32_Product -ComputerName $ComputerName | Select-Object -Property Name | Out-GridView -Title \"All apps on destination Computer\"
$Name = Read-Host -Prompt \'Input name of the application (has to be exact name)\' #name of the application
$Application = Get-WmiObject Win32_Product -ComputerName $ComputerName | Where-Object {$_.Name -eq $Name} #choose the object, this will be the app that we will delete
if ($Application) {
$Application.Uninstall()
\"
The removal was successful\"
}
else {
$Name + \' is not installed on \' + $ComputerName
}
Start-Sleep -Seconds 10
-
.exe 没有通用的方法。您可以尝试从registry 中读取
QuietUninstallString值,但它是可选的。只有UninstallString是强制性的,在许多情况下会打开卸载程序GUI。 stackoverflow.com/a/68226698/7571258 -
谢谢各位,很有道理
标签: powershell windows-installer exe wmi