uttara bhosale
uttara bhosale

Reputation: 107

Powershell: opening the cmd.exe and then running commands on cmd

I am trying to open the command prompt using powershell and then run an exe file with parameters.

Start-Process cmd.exe -Credential $credential

Once cmd opens I want to run remotely an exe, e.g:

abc.exe -a arg1 -h arg2

How do I do the second part with Powershell, using the same credentials?

Upvotes: 4

Views: 11441

Answers (1)

Jeff Zeitlin
Jeff Zeitlin

Reputation: 10799

You can't do it as two separate steps; however, if you invoke Start-Process as

Start-Process cmd.exe -Credential $Credential -ArgumentList "/C abc.exe -a arg1 -h arg2"

you will accomplish what you appear to need.

Upvotes: 4

Related Questions