PSADT以System账户运行时Setup.exe解压MSI路径异常求助
解决PSADT在SYSTEM账户下安装ReadSoft Forms的路径重定向问题
核心问题分析
这是典型的Windows 32位/64位文件系统重定向导致的问题:
- 64位上下文运行的PSADT启动32位的
setup.exe时,setup.exe会将MSI解压到C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Downloaded Installations\...(32位程序的默认用户目录重定向路径) - 但
setup.exe调用的32位msiexec.exe(来自C:\Windows\SysWOW64)尝试访问硬编码的C:\Windows\system32\config\systemprofile\...路径时,无法匹配实际解压位置,最终触发ERROR_INSTALL_SOURCE_ABSENT错误。
解决方案1:直接提取MSI并手动安装(最可靠)
绕过setup.exe的自动解压流程,手动提取MSI后直接调用msiexec安装,完全避免路径重定向问题:
# 创建临时提取目录 $extractDir = Join-Path $env:TEMP "ReadSoftForms_Extract" New-Item -Path $extractDir -ItemType Directory -Force | Out-Null # 从setup.exe提取MSI(多数InstallShield打包程序支持/extract参数) Execute-Process -Path $File.FullName -parameters "/extract:`"$extractDir`" /quiet" -Passthru # 查找提取后的MSI文件 $targetMSI = Get-ChildItem -Path $extractDir -Filter "*.msi" -Recurse | Select-Object -First 1 -ExpandProperty FullName if ($targetMSI) { # 直接安装MSI Execute-Process -Path "msiexec.exe" -parameters "/i `"$targetMSI`" /qn /l*v `"$Log`"" -Passthru } else { Write-Log "未找到提取的MSI文件,安装失败" -Severity Error Exit-Script -ExitCode 1 } # 清理临时目录(可选) Remove-Item -Path $extractDir -Recurse -Force -ErrorAction SilentlyContinue
注意
如果/extract参数无效,可尝试InstallShield的其他提取参数:/a(管理安装)或/s /t:<路径>。
解决方案2:禁用文件系统重定向
在执行setup.exe前,临时禁用64位进程的32位文件系统重定向,让setup.exe将MSI解压到64位SYSTEM账户的默认路径(C:\Windows\system32\config\systemprofile\...),这样32位msiexec访问该路径时会被正确重定向:
# 禁用32位文件系统重定向 $originalRedirectState = [System.Environment]::DisableWow64FsRedirection() try { # 执行setup.exe安装 Execute-Process -Path $File.FullName -parameters "/S /v`"/qn /l*v `"$Log`"`""" -Passthru } finally { # 恢复文件系统重定向(必须执行,避免影响后续操作) if ($originalRedirectState -ne $null) { [System.Environment]::EnableWow64FsRedirection($originalRedirectState) } }
解决方案3:指定setup.exe的临时解压路径
部分打包程序支持指定临时解压目录,将MSI解压到非系统目录(如%TEMP%),避开systemprofile的重定向问题:
# 指定临时解压路径 $tempExtractPath = Join-Path $env:TEMP "ReadSoftForms_Temp" New-Item -Path $tempExtractPath -ItemType Directory -Force | Out-Null # 传递/t参数指定解压目录(适用于InstallShield程序) Execute-Process -Path $File.FullName -parameters "/S /t `"$tempExtractPath`" /v`"/qn /l*v `"$Log`"`""" -Passthru # 清理临时目录(可选) Remove-Item -Path $tempExtractPath -Recurse -Force -ErrorAction SilentlyContinue
内容的提问来源于stack exchange,提问作者arker
相关产品推荐
相关产品推荐

