Start-Process -FilePath $application.UninstallString -ArgumentList "/q" -Wait -NoNewWindow
Start-Process -FilePath $application.UninstallString -ArgumentList "/s" -Wait -NoNewWindow
Start-Process -FilePath $application.UninstallString -ArgumentList "-q" -Wait -NoNewWindow
我尝试使用上述命令卸载应用程序,但是当我运行它时会提示确认窗口,我想阻止窗口显示。
答案 0 :(得分:2)
PoSH只是启动安装程序/卸载程序(.msi,.exe)。如果安装程序/ uininstaller没有静默选项,PoSH就无法做到这一点。 RegKey卸载字符串仅调用用于部署应用程序的原始安装程序。
请参阅此帖以进行类似的讨论。
Using the WMI object takes forever. This is very fast if you just know the name of the program you want to uninstall.
$uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "SOFTWARE NAME" } | select UninstallString
$uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "SOFTWARE NAME" } | select UninstallString
if ($uninstall64) {
$uninstall64 = $uninstall64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall64 = $uninstall64.Trim()
Write "Uninstalling..."
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..."
start-process "msiexec.exe" -arg "/X $uninstall32 /qb" -Wait}
其他例子:
$javaVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "java" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $javaVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
& cmd /c $uninst /quiet /norestart
}
}
通过远程或本地计算机搜索和卸载软件 的powershell
此脚本搜索并尝试卸载某个软件 按产品名称。它查询SCCM客户端的WMI类 product,找到卸载字符串并执行卸载字符串。
https://gallery.technet.microsoft.com/scriptcenter/Search-for-and-Uninstall-8c2c457e