Windows shell command to get the full path to the current directory?

前端 未结 14 1747
一向
一向 2020-11-30 17:51

Is there a Windows command line command that I can use to get the full path to the current working directory?

Also, how can I store this path inside a variable used

14条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 18:42

    You can set a batch/environment variable as follows:

    SET var=%cd%
    ECHO %var%
    

    sample screenshot from a Windows 7 x64 cmd.exe.

    enter image description here

    Update: if you do a SET var = %cd% instead of SET var=%cd% , below is what happens. Thanks to jeb.

    enter image description here

    Capturing the current directory from a batch file

提交回复
热议问题