【发布时间】:2014-12-23 17:34:02
【问题描述】:
我有一个带有 TargetPlatform x64 位模式的 msi。我还在以 32 位模式运行的机器上安装了 PowerShell 2.0。我已经使用 powershell 脚本安装了 msi。现在,当我尝试使用下面提到的 powershell 脚本卸载 msi 时,出现错误:
找不到应用程序TestSetup
function Uninstall-MSI([string]$name)
{
$success = $false
# Read installation information from the registry
$registryLocation = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
foreach ($registryItem in $registryLocation)
{
# If we get a match on the application name
if ((Get-itemproperty $registryItem.PSPath).DisplayName -eq $name)
{
# Get the product code if possible
$productCode = (Get-itemproperty $registryItem.PSPath).ProductCode
# If a product code is available, uninstall using it
if ([string]::IsNullOrEmpty($productCode) -eq $false)
{
Write-Host "Uninstalling $name, ProductCode:$code"
$args="/uninstall $code"
[diagnostics.process]::start("msiexec", $args).WaitForExit()
$success = $true
}
# If there is no product code, try to read the uninstall string
else
{
$uninstallString = (Get-itemproperty $registryItem.PSPath).UninstallString
if ([string]::IsNullOrEmpty($uninstallString) -eq $false)
{
# Grab the product key and create an argument string
$match = [RegEx]::Match($uninstallString, "{.*?}")
$args = "/x $($match.Value) /qn"
[diagnostics.process]::start("msiexec", $args).WaitForExit()
Write-Host $uninstallString
$success = $true
}
else { throw "Unable to uninstall $name" }
}
}
}
if ($success -eq $false)
{ throw "Unable to find application $name" }
}
Uninstall-MSI "TestSetup"
然后我将 MSI 更新为 x86 位模式并执行安装,然后尝试使用上述相同的 powershell 脚本进行卸载。它对我有用,没有任何问题。
谁能帮我解决上述问题?
【问题讨论】:
标签: windows-installer powershell-2.0