简体   繁体   中英

start-process, ArgumentList issue via powershell

Trying to invoke cmd via powershell and pass on arguments that will change directory on cmd to c:\\pilot

Sample code that I tried doing this via start-process:

Start-Process "C:\Users\su\AppData\Roaming\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk" -ArgumentList 'C:\pilot'

so after running this, it appears to pop up a new cmd window, but doesn't change the directory to c:\\pilot , is there a special format in sending arguments to cmd?

From an earlier revision of your question:

ultimately I am trying to change directory and also pass on an command for execution on the 2nd window without closing the second window.

The following opens a stay-open cmd.exe console window ("Command Prompt") in working directory C:\\pilot and executes command date /t

 Start-Process cmd -WorkingDirectory C:\pilot -ArgumentList '/k', 'date /t'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM