[英]Calling a PowerShell script from Wix with Parameters
我正在為此苦苦掙扎,因為 Wix CustomAction 使用一組參數(包括 PowerShell 腳本)調用 PowerShell.exe,但隨后我需要將其他參數傳遞給 powershell 腳本。 我試圖簡化,在不同的地方嘗試了各種引號來嘗試在邏輯上分離參數,但我沒有運氣。 這是我所擁有的:
<SetProperty Id="ReplaceConnectionString"
Before ="ReplaceConnectionString"
Sequence="execute"
Value=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File "[INSTALLFOLDER]ReplaceConnectionString.ps1" "MyParam"" />
<CustomAction Id="ReplaceConnectionString" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="ReplaceConnectionString" After="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>
我究竟做錯了什么?
我找到的解決方案正如 Mathias 建議的那樣,即使用參數名稱。
另一個問題是 PowerShell 不喜歡參數上的尾隨 /,這是通過向參數添加額外的 / 來解決的。 這是我的結論:
<SetProperty Id="ReplaceConnectionString"
Before ="ReplaceConnectionString"
Sequence="execute"
Value=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File "[INSTALLFOLDER]ReplaceConnectionString.ps1" -servername "[DB_SERVER]" -database "[DB_DATABASE]" -configPath "[INSTALLFOLDER]\"" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.