I'm attemting to do something probably pretty easy.
I'm trying to allow users of a windows batch script to set the background colour and store it in a txt file which is then loaded into a variable each time they run the script.
So far I have:
set /p ColourOpt=<%LogPath%\%UserName%_Options.Colour.log
Which loads the contents of the .log file into the ColourOpt variable (%username% and %logpath% are already defined and are working fine).
Then I use the following code to apply the option:
If /I '%Colouropt%'=='0f' Color 0f
If /I '%Colouropt%'=='08' Color 08
If /I '%Colouropt%'=='0c' Color 0c
If /I '%Colouropt%'=='0d' Color 0d
If /I '%Colouropt%'=='0e' Color 0e
If /I '%Colouropt%'=='0a' Color 0a
If /I '%Colouropt%'=='1a' Color 1a
If /I '%Colouropt%'=='1c' Color 1c
If /I '%Colouropt%'=='1e' Color 1e
If /I '%Colouropt%'=='1f' Color 1f
This also works fine and the colour is set without issue.
Now the problem, When i use the script to output the users colour setting to the .log file it adds spaces, which now cause the script to close instead of applying the change.
The code used to write to the .log file:
IF /I '%Options%'=='1' Echo 0f>%LogPath%\%UserName%_Options.Colour.log & Set ColourOpt=0f & Color 0f
This will save the option to the .log file and set the colour straight away, aswell as setting it in the variable.
However this outputs the text file with a space after "0f" and a blank line under it.
Is there a way to output without the spaces, or allow the if command to ignore spaces?
Any help would be greatly apreciated!
Thanks!