[英]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 尝试通过Powershell调用cmd并传递将cmd目录更改为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? 因此,在运行此命令之后,它似乎会弹出一个新的cmd窗口,但不会将目录更改为
c:\\pilot
,在向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
下面的代码在工作目录
C:\\pilot
打开一个保持打开状态的cmd.exe
控制台窗口(“命令提示符”),并执行命令date /t
Start-Process cmd -WorkingDirectory C:\pilot -ArgumentList '/k', 'date /t'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.