Invalid syntax with setx

前端 未结 3 1929
被撕碎了的回忆
被撕碎了的回忆 2020-12-30 23:52

I used the setx command to set OGRE_HOME:

setx OGRE_HOME D:\\Program Files\\OgreSDK

Now I need to change to value

3条回答
  •  囚心锁ツ
    2020-12-31 00:33

    setx and pretty much all windows command line commands are sensitive to certain special characters. Among them the space character but there's also the quote which is used to delimit an entry.

    As @ajp15243 already said, you can deal with the space by locking off the path{s) between two quotations. But what if you have paths and those path already have quotations because they carry a space? Here's an example:

    MY_PATHS="c:\Program Files\path1";"c:\Program Files(x86)\Path2"
    

    In this case, you would have to put escape characters for those inner quotation marks when you use setx or it will get confused and give the error you listed. Eg:

    setx -m MY_PATHS "\"c:\Program Files\path1\";\"c:\Program Files(x86)\Path2\""
    
    | improve this answer | |

提交回复
热议问题