我有一個文件夾位於具有文件input.xml,output.xml和licensegenerator.exe的C:\ Folder中。 Licensegenerator.exe將變量放入input.xml中,並使用output.xml文件爲我們的某個程序創建一個臨時許可證。我們通常通過命令行執行此導航到C:\文件夾目錄,然後運行命令:如何從PowerShell運行* .exe文件
LicenseGenerator.exe "C:\Folder\input.xml" "C:\Folder\output.xml"
我試圖寫一個腳本做在PowerShell中完全一樣的事情,但我掙扎......這是我有:
$inputtest = "C:\Folder\Input.xml"
$outputtest = "C:\Folder\Output.xml"
$licensegen = "C:\Folder\LicenseGenerator.exe"
Invoke-Command $licensegen "$inputtest" "$outputtest"
當我運行它,我得到的錯誤:
Invoke-Command : A positional parameter cannot be found that accepts argument 'C:\Folder\Output.xml'. At line:5 char:1 + Invoke-Command $licengegen "$inputtest" "$outputtest" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeCommandCommand
我也試圖與Invoke-Expression
運行,但得到完全相同的錯誤(除非它說「 Invoke-Expression「開頭)。任何人都知道我在這裏做錯了什麼?
&$ licensegen 「$ inputtest」 取代調用命令 「$ outputtest」 的伎倆。謝謝你們! –