Passing a PowerShell parameter to an executable using switches

I turn to converting abc.exe / u "c: /programs/abc.dll" into a powershell script can someone explain how to do this.

how can i execute * .exe with switches with options

thank..

Solar

+5
source share
2 answers

It should be as direct as:

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

However, you may encounter problems with quoting and other characters that are interpreted by PowerShell. Normally a quouting argument will suffice, but if it still does not work, you can use the Start-Process in PowerShell 2.0, for example:

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

PowerShell, echoargs.exe args exe. :.

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

Echoargs , EXE.

+4

, :

$psi = New-Object System.Diagnostics.ProcessStartInfo "abc.exe"
$psi.Arguments = "/u c:/programs/abc.dll"
[System.Diagnostics.Process]::Start($psi)

: System.Diagnostics.ProcessStartInfo.

+1

All Articles