1.

Solve : Having trouble setting a variable from a text with batch.?

Answer»

Hello all,

Just as the topic states, I cannot set a variable from an entry in a text FILE due to a space at the end of the entry. For example the program WRITES to the file here:

Code: [Select]ECHO %user% >> user.ini
Then attempts to read from it here:

Code: [Select]set /p user= <user.ini
But when it reads the VALUE its got a space at the end. This is unacceptable because this variable is used for a directory.
My QUESTION is, is there any way to remove a character from the end of the input? Or any other way around this?Code: [Select]ECHO %user% >> user.iniIs not right.Quote from: Geek-9pm on November 29, 2009, 10:29:30 PM

Code: [Select]ECHO %user% >> user.iniIs not right.

Thanks for that wonderful piece of help...

I realized my MISTAKE, your right it's not:

Code: [Select]ECHO %user% >> user.iniits
Code: [Select]ECHO %user%>> user.ini
Thanks anyhow, its working now.Quote from: Geek-9pm on November 29, 2009, 10:29:30 PM
Code: [Select]ECHO %user% >> user.iniIs not right.

Unless the trailing space after %user% does not matter. In some situations it might not.


Discussion

No Comment Found