Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4572746
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:41:22+00:00 2026-05-21T19:41:22+00:00

I’m attemting to do something probably pretty easy. I’m trying to allow users of

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:41:22+00:00Added an answer on May 21, 2026 at 7:41 pm

    Why are you trying to do it as a single operation? Windows has had multi-line if blocks for ages:

    IF /I '%Options%'=='1' (
        Echo 0f>%LogPath%\%UserName%_Options.Colour.log
        Set ColourOpt=0f
        Color 0f
    )
    

    It’s actually the space preceding the first & which is being output to the file, you could equally well fix that with:

    IF /I '%Options%'=='1' Echo 0f>%blah%_Options.Colour.log& Set ColourOpt=...
    

    (no space in there).

    If you don’t even want the line endings (i.e., if you want your file to consist of only 0f), you already know half the trick:

    <nul set /p junk=0f>xyz.txt& echo hello
    

    This will create a file xyz.txt with only those two characters – no extra space and no line ending afterwards.

    See this answer for more information and all the other answers, including some more of mine, for some neat tricks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.