我正在尝试使用Script.Shell.Exec来运行PowerShell脚本,我遇到了参数问题。一个简单的命令行实用程序工作正常,比如说
strCmd = "%comspec% /c tasklist"
没有参数的PowerShell工作正常,如
strCmd = "powershell.exe -noLogo -noProfile -executionPolicy bypass -file ""\\Mac\Px\Support\Px Tools\Dev 3.3.#\_Spikes\TestMessage.ps1"""
但是引入这样的论点,它失败了。
strCmd = "powershell.exe -noLogo -noProfile -executionPolicy bypass -file ""\\Mac\Px\Support\Px Tools\Dev 3.3.#\_Spikes\TestMessage.ps1"" -message:""It's ALIVE!"""
我也尝试制作一个数组并在.Exec中使用该数组,就像这样
strCmd = "powershell.exe -noLogo -noProfile -executionPolicy bypass -file ""\\Mac\Px\Support\Px Tools\Dev 3.3.#\_Spikes\TestMessage.ps1"" -message:""It's ALIVE!"""
strArgument = "-message:""It's ALIVE!"""
arrCmd = Array(strCmd, strArgument)
我很难过。