简体   繁体   中英

How can I change directory directly from the windows run prompt?

How can I change the current directory from the the windows run prompt when we initialize powershell as powershell . For eg: powershell --someArgs

Launch cmd.exe and use the builtin start command's /d flag to launch powershell.exe with a specific working directory:

cmd /c start /d "C:\working\directory\goes\here" powershell.exe

This will set the working directory of the powershell.exe process to C:\working\directory\goes\here , in turn causing PowerShell's $PWD to change to that directory

You can use Set-Location or Cd

Powershell.exe -noexit -Command "CD 'C:\Test\'"


Powershell.exe -noexit -Command "Set-Location 'C:\Test\'"

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