1

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" ) 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?

shan
  • 493
  • 2
  • 5
  • 10

3 Answers3

4

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"

Brad
  • 159,648
  • 54
  • 349
  • 530
  • @Brad did u try it with your self? – shan May 16 '11 at 00:25
  • @shan, Yes, I did try it myself, and it works fine for me. If it isn't working for you, did you make sure that you are setting the variable correctly? – Brad May 16 '11 at 00:49
  • @Brad Are u working on windows? What is your cd refer to? if the folder names doesn't any space this works, if there is a spaces this is not work – shan May 16 '11 at 01:00
  • @shan, Yes, I am using Windows, and yes it does work. Try it yourself using %ProgramFiles%. You must be defining %cd% incorrectly. – Brad May 16 '11 at 01:02
  • 1
    @shan, `%cd%` is set to the current directory by the system! Why do you need to use it at all? Just call mygame.exe if you are in the correct path. – Brad May 16 '11 at 01:04
  • @Brad because i am not in a working directory,I am try to copy bat file to another location with data.not ProgramFiles Program files.Please give correct answer, when you give the answer,otherwise you are misleading others,Don't ask me to try,I am trying to do it – shan May 16 '11 at 01:12
  • @Brad In your solution, it only open another console – shan May 16 '11 at 01:14
2

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

gadosa
  • 71
  • 2
2

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"
sakra
  • 62,199
  • 16
  • 168
  • 151