Set a path variable with spaces in the path in a Windows .cmd file or batch file

前端 未结 9 741
孤独总比滥情好
孤独总比滥情好 2020-12-02 05:43

I\'m new to script writing and can\'t get this one to work. I could if I moved the files to a path without a space in it, but I\'d like it to work with the space if it coul

相关标签:
9条回答
  • 2020-12-02 06:43

    The easiest way to fix this problem is to put the folder name in quotes:

    (cd\New Folder\...) --> (cd\"New Folder"\...)

    Hopes this helps.

    0 讨论(0)
  • 2020-12-02 06:48

    If you need to store permanent path (path is not changed when cmd is restart)

    1. Run the Command Prompt as administrator (Right click on cmd.exe and select run as administrator)

    2. In cmd setx path "%path%;your new path" then enter

    3. Check whether the path is taken correctly by typing path and pressing enter

    0 讨论(0)
  • 2020-12-02 06:49

    I use

    set "VAR_NAME=<String With Spaces>"
    

    when updating path:

    set "PATH=%UTIL_DIR%;%PATH%"
    
    0 讨论(0)
提交回复
热议问题