views:

51

answers:

1

Hello,

I am coding a batch file. Here is a sample:

if exist rootsys.txt del rootsys.txt
if %lang%==1 (
if %bit%==32 echo C:\Program Files\path\to\the dir>rootsys.txt
if %bit%==64 echo C:\Program Files(x86)\path\to\the dir>rootsys.txt
goto :waset
)

This goes on for six times (so if %lang%==2 etc... to if %lang%==6.)

So, what it does, the user puts something in, like '6', so it will do the thing for the sixth.

But, whenever i try this, it ends up with \the was unexpected at this time. So, i tried debugging with @echo on. Seemed that it gave me the error at if exist rootsys.txt del rootsys.txt. How can that happen?!

I am 110% sure i do not mention the(actually i use this as a sample, it has another name) nowhere else in my batch file. Can anyone help me? I am really stuck here.

+1  A: 

enclose the C:\Program Files\path\to\the dir string with "

Alon
if i would `set /p path=<rootsys.txt`, will it also come out with quotes?
YourComputerHelpZ
no, the set command takes everything the right of the equal character and assigns it to the variable so no quotes are needed
Alon
btw: it works however. thanks. i don't need an answer anymore to the question above
YourComputerHelpZ