How can I execute an external program with parameters in PowerShell? -


i have read answer stackoverflow answer , get's me there half way. here need do.

execute command:

"c:\myexe.exe <c:\users\me\myanswerfile.txt" 

if run straight within powershell script

&'c:\myexe.exe <c:\users\me\myanswerfile.txt' 

i error:

the term 'c:\myexe.exe <c:\users\me\myanswerfile.txt' not recognized name of cmdlet, function, script file, or operable program. check spelling of name,or  if path included, verif path correct , try again. 

now have tried several variations of including placing original command in variable called $cmd , passing

if append '<' $cmd variable command fails similar error first one.

i'm stumped. suggestions?

if want run program, type name , parameters:

notepad.exe c:\devmy\hi.txt 

if want run exe , redirect stdin example seems attempt of, use:

get-content c:devmy\hi.txt | yourexe.exe  

if need specify full path program need use ampersand , quotes otherwise powershell thinks defining plain string:

&"c:\program files (x86)\notepad++\notepad++.exe" 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -