当我们将powershell初始化为powershell
时,如何从windowsrun
提示符更改当前目录。例如:powershell --someArgs
您可以使用Set Location或Cd
Powershell.exe -noexit -Command "CD 'C:Test'"
Powershell.exe -noexit -Command "Set-Location 'C:Test'"
启动cmd.exe
并使用内置的start
命令的/d
标志启动具有特定工作目录的powershell.exe
:
cmd /c start /d "C:workingdirectorygoeshere" powershell.exe
这将把powershell.exe
进程的工作目录设置为C:workingdirectorygoeshere
,从而导致PowerShell的$PWD
更改为目录