开发者

prevent the problem of space in windows folders in the command line

开发者 https://www.devze.com 2023-03-05 22:11 出处:网络
As we know that windows, we can create folders with a name contains spaces(Hello World,New Folder,My Programs). In the commandline if we use start c:\\Hello World\\mygame.exe , it gives error called H

As we know that windows, we can create folders with a name contains spaces(Hello World,New Folder,My Programs). In the commandline if we use start c:\Hello World\mygame.exe , it gives error called Hello is not found. it split the word from the space, to avoid this we can use thid start c:\"Hello World"\mygame.exe. my problem is this set x=%cd% (Here cd is "c:\Hello World开发者_C百科" ) and we execute mygame.exe using this command "start %cd%\mygame.exe" which gives error of Hello is not found. Anyone knows solution for this?


Instead of putting quotes around just part of the path, put quotes around the entire path. If you do that, you should be fine.

start "%cd%\mygame.exe"


In the set command put quotes around the whole assignment:

set "x=%cd%"

In the start command, use quotes as well:

start "%x%\mygame.exe"


for example, if you have a folder name FOO FOO with a space and you want to access from cmd yo just do:

cd "FOO FOO"

That's all

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号