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

  • SEARCH
  • Home
  • 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 6149367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:26:25+00:00 2026-05-23T19:26:25+00:00

When defining an environment variable (on Windows for me, maybe there is a more

  • 0

When defining an environment variable (on Windows for me, maybe there is a more general guideline)

set MY_TOOL=C:\DevTools\bin\mytool.exe

if the tool is located on a path with spaces

set MY_TOOL=C:\Program Files (x86)\Foobar\bin\mytool.exe

should the environment variable already contain the necessary spaces?

That is, should it read:

set MY_TOOL="C:\Program Files (x86)\Foobar\bin\mytool.exe"

instead of the above version without spaces?

Note: In light of Joeys answer, I really should narrow this question to the examples I gave. That is, environment variables that contain one single (executable / batch) tool to be invoked by a user or by another batch script.

Maybe the spaces should be escaped differently?

  • 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-23T19:26:26+00:00Added an answer on May 23, 2026 at 7:26 pm

    I’d say, do it without quotes and use them everywhere you use the variable:

    set MY_TOOL=C:\Program Files (x86)\Foobar\bin\mytool.exe
    
    "%MY_TOOL%" -someoption someargument somefile
    

    Especially if you let the user set the value somewhere I guess this is the safest option, since they usually tend not to surround it with quotes rather than do so.

    If there are plenty of places where you use the variable you can of course redefine:

    set MY_TOOL="%MY_TOOL%"
    

    which makes things more resilient for you. Optionally you could detect whether there are quotes or not and add them if not present to be totally sure.

    When your variable represents only a path to a directory and you want to append file names there, then the “no quotes” thing is even more important, otherwise you’d be building paths like

    "C:\Program Files (x86)\Foobar\bin"\mytool.exe
    

    or even:

    ""C:\Program Files (x86)\Foobar\bin"\my tool with spaces.exe"
    

    which I doubt will parse correctly.

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

Sidebar

Related Questions

I see that there is the SVN_EDITOR environment variable to define what editor to
In Visual Studio 2003, I am trying to set an environment variable in the
Defining custom components in Facelets is easy and quick but there's one thing I
When defining a custom operator from the limited set of single-character operators that can
I want to separate the debug outputs from production ones by defining a variable
I'm having a simple GUI environment with a button widget (a jQuery plugin). There's
When defining an ASyncTask and it associated methods in Android there are 3 dots
When defining a method on a class in Python, it looks something like this:
When defining parameter type that is e.g. in System.Data you have no intellisense and
Atleast defining my problem is simple... I have a Input control (Text) and a

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.