我正在尝试使用 powershell 调用 perl 脚本,如下所示:
$plScript = Join-path $pwd 'Tools\myScript.pl'
$plOut = New-Item out.txt -type file -force
$plArgs = @($plScript, '--files','*.c', 'AddInc=\Tools','Addlib=\Tools')
Start-Process perl.exe -ArgumentList $plArgs -RedirectStandardOutput $plOut - wait
这失败并显示以下消息:
Start-Process : Process with an Id of 80096 is not running.
+ Start-Process <<<< perl.exe -ArgumentList $plArgs -RedirectStandardOutput $plOut -wait
+ CategoryInfo : NotSpecified: (:) [Start-Process], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.StartProcessCommand
使用 Trace-Command,我看到了失败的地方,但不明白出了什么问题
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : System.ArgumentException: Process with an Id of 150588 is not running.
at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
at Microsoft.PowerShell.Commands.StartProcessCommand.start(ProcessStartInfo startInfo)
at Microsoft.PowerShell.Commands.StartProcessCommand.BeginProcessing()
at System.Management.Automation.Cmdlet.DoBeginProcessing()
at System.Management.Automation.CommandProcessorBase.DoBegin()
我错过了什么?
在 powershell v3 中运行它成功,没有错误......但我必须支持 v2 来完成这个任务......