DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Allowed Characters in Windows Environment Variable Names  (Read 8,488 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Does any one have any pointers to references regarding the allowed characters in Windows Environment Variable names?

I found the following for *nix:

  Allowed characters in linux environment variable names

MSDN has:

Quote
The name of an environment variable cannot include an equal sign (=).

Was hoping to find something that spelled things out a bit more...

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: Allowed Characters in Windows Environment Variable Names
« Reply #1 on: May 21, 2011, 11:42 AM »
Though Windows seems to support Unicode environment variables, not all applications support them, and probably wont get that support until they are 'upgraded' to support Unicode from the ground up 8).

Any time I've had to define my own, I sticked with plain ascii characters a-z and 0-9, and sometimes an '_', anything else could turn up problematic in a batch file (where I use environment vars primarily).

If it's for use in your own application, and you want users to set them from the standard Windows configuration screens, I'd stick with things typable on a standard US keyboard, or else the instructions to set them could be awkward, at least.
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: Allowed Characters in Windows Environment Variable Names
« Reply #2 on: May 23, 2011, 08:34 AM »
Thanks for the response.

I'm trying to write a small wrapper program to launch other programs and would like to be able to configure it via some simple settings file.  I'd like to be able to specify environment variable name and value pairs in the settings file and as a part of that I'd like to check the specific name, value pairs -- I'd prefer not to blindly take what's been specified and pass them on to a function to modify environment variables...

I tend to stick to alphanumeric plus underscore, but I notice via experimentation that other things seem to work.  Perhaps for initial versions I'll stay on the strict side.

Original address: https://www.donationcoder.com/forum/index.php?topic=26816.0