如何直接从windows运行提示符更改目录



当我们将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更改为目录

最新更新