我试图获得一组应用程序的卸载路径并卸载它们。到目前为止,我得到了卸载路径列表.但我很难真正卸载这些程序。
到目前为止我的代码是。
$app = @("msi1", "msi2", "msi3", "msi4")
$Regpath = @(
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
foreach ($apps in $app){
$UninstallPath = Get-ItemProperty $Regpath | where {$_.displayname -like "*$apps*"} | Select-Object -Property UninstallString
$UninstallPath.UninstallString
#Invoke-Expression UninstallPath.UninstallString
#start-process "msiexec.exe" -arg "X $UnistallPath /qb" - wait
}这将返回以下结果:
MsiExec.exe /X{F17025FB-0401-47C9-9E34-267FBC619AAE}
MsiExec.exe /X{20DC0ED0-EA01-44AB-A922-BD9932AC5F2C}
MsiExec.exe /X{29376A2B-2D9A-43DB-A28D-EF5C02722AD9}
MsiExec.exe /X{18C9B6D0-DCDC-44D8-9294-0ED24B080F0C}我很难找到执行这些卸载路径和实际卸载MSI的方法。
我尝试过使用Invoke-Expression $UninstallPath.UninstallString,但它只显示windows安装程序,并为msiexec提供了选项。
我也尝试过使用start-process "msiexec.exe" -arg "X $UnistallPath /qb" - wait,但是这也带来了同样的问题。
发布于 2021-07-14 18:09:54
或者,例如:
get-package *chrome* | uninstall-packagehttps://stackoverflow.com/questions/68382074
复制相似问题