Arun
Arun

Reputation: 21

Executing a cmd in cmd prompt opened via powershell script

I am trying to automate a scenario, where i need to open a cmd prompt with cd to path, which i am able to achieve with:

Start-Process -FilePath "cmd.exe" -ArgumentList "/K cd /d C:\Program Files (x86)\Folder\" -Verb "runas"

Further, i need to execute a cmd "ab.exe -i name url" in the cmd prompt opened as a result of executing the above code. I am trying this via powershell scripting.

Upvotes: 0

Views: 54

Answers (1)

zett42
zett42

Reputation: 27756

You can concatenate multiple commands using & or && operator. The latter only runs the 2nd command if the first one was successfull.

-ArgumentList "/K cd /d C:\Program Files (x86)\Folder\ && ab.exe -i name url"

Upvotes: 2

Related Questions