Windows installer 无法使用32位PowerShell卸载x64 TargetPlatform msi
我有一个目标平台x64位模式的msi。我的机器中也安装了PowerShell 2.0,它以32位模式运行。我已经使用powershell脚本安装了msi。现在,当我尝试使用下面提到的powershell脚本卸载msi时,我收到一个错误: 找不到应用程序TestSetupWindows installer 无法使用32位PowerShell卸载x64 TargetPlatform msi,windows-installer,powershell-2.0,Windows Installer,Powershell 2.0,我有一个目标平台x64位模式的msi。我的机器中也安装了PowerShell 2.0,它以32位模式运行。我已经使用powershell脚本安装了msi。现在,当我尝试使用下面提到的powershell脚本卸载msi时,我收到一个错误: 找不到应用程序TestSetup function Uninstall-MSI([string]$name) { $success = $false # Read installation information from the regist
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脚本进行卸载。这对我来说没有任何问题
有人能帮我解决上述问题吗?我进一步分析了这个问题,发现在我的机器中,Powershell进程以32位模式运行,而msi则以TargetPlatform x64位模式运行。在32位模式下运行的Powershell进程无法读取64位模式应用程序的注册表项。我在一台web服务器上测试了同样的功能,在该服务器上,Powershell以x64位模式运行,msi以TargetPlatform x64位模式运行,对我来说效果很好