簡體   English   中英

PowerShell:使用“啟動進程”調用並行拋出錯誤

[英]PowerShell: Invoke-Parallel throwing error with “start-process”

我使用的是Invoke-Parallel CmdLet,可在此處的鏈接中找到 當我的腳本塊中有一些偽代碼時,它可以正常工作,但是當我添加啟動過程...命令時,它將失敗,並顯示錯誤消息

Get-RunspaceData : This command cannot be run due to the error: The system    
cannot find the file specified.
At c:\crm\Interfaces\Batches\Invoke-Parallel.ps1:592 char:13

我的腳本塊看起來像這樣。 長話短說,我將文件名輸入到一個塊中,並告訴第3方應用程序將該文件用作流程的輸入。 刪除啟動過程行后,它可以工作,並且失敗。

$childFiles| Invoke-Parallel -ImportVariables {
    $importformat = '-f ' + '"CU Imp P19 FI"'
    $importfile = '-d ' + $_ + " " + $user + " " + $pass        
    Write-Host $importformat + " " + $_
    start-process .\mmim.exe -ArgumentList  $user, $pass, '-l:1', 
    $importformat, $importfile -Wait -NoNewWindow
    return "blah"
}

有誰知道會發生什么事嗎? 我的PowerShell版本如下

專業:5

次要:0

建立:10586

修訂:117

任何幫助是極大的贊賞。

每個PowerShell運行空間都有其自己的當前位置。 如果Invoke-Parallel不會更改生成的運行空間的當前位置以匹配主運行空間的當前位置,則相對路徑.\\mmim.exe可能會解析為整個不同的可執行文件,或者根本不會解析並產生給定的錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM