我已经阅读了这个答案stackoverflow的答案,它让我在那里中途.这是我需要做的.
执行以下命令:
"c:\myexe.exe <c:\Users\Me\myanswerfile.txt"
Run Code Online (Sandbox Code Playgroud)
如果我从我的powershell脚本中直接运行它
&'c:\myexe.exe <c:\Users\Me\myanswerfile.txt'
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
The term 'C:\myexe.exe <c:\Users\Me\myanswerfile.txt' is not recognized as the name of
a cmdlet, function, script file, or operable program. Check the spelling of the name,or
if a path was included, verif that the path is correct and try again.
Run Code Online (Sandbox Code Playgroud)
现在我尝试了几种变体,包括将原始命令放在一个名为$ cmd的变量中,然后传递
如果我将'<'附加到$ cmd变量,则命令失败并出现与第一个类似的错误.
我很难过.有什么建议?
Bjö*_*ist 20
如果要运行程序,只需键入其名称和参数:
notepad.exe C:\devmy\hi.txt
Run Code Online (Sandbox Code Playgroud)
如果你想运行一个exe并将stdin重定向到你的例子似乎是一个尝试,请使用:
Get-Content c:devmy\hi.txt | yourexe.exe
Run Code Online (Sandbox Code Playgroud)
如果您需要指定程序的完整路径,那么您需要使用&符号和引号,否则powershell认为您正在定义一个纯字符串:
&"C:\Program Files (x86)\Notepad++\notepad++.exe"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
33935 次 |
最近记录: |