Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell passing parameter to executable having switches

Tags:

powershell

i am tring to convert abc.exe /u "c:/programs/abc.dll" to powershell script can anybody explain how to do it.

how can i execute the *.exe having switches with parameters??

thanks..

Sunny

like image 582
uaslam Avatar asked Sep 25 '10 17:09

uaslam


1 Answers

It should be as straight forward as:

C:\PS> abc.exe /u c:/programs/abc.dll

However you can run into issues with quoting and other characters that get interpreted by PowerShell. Usually quouting an argument will suffice but if that still doesn't work you can use Start-Process in PowerShell 2.0 e.g.:

C:\PS> start-process abc.exe -arg @'
...
'@

If you have PowerShell Community Extensions installed you can use a utility called echoargs.exe to troubleshoot passing args to exe's. e.g.:

C:\PS> echoargs /u c:/programs/abc.dll
Arg 0 is </u>
Arg 1 is <c:/programs/abc.dll>

Echoargs display the arguments exactly as the EXE sees them.

like image 114
Keith Hill Avatar answered Oct 11 '22 17:10

Keith Hill