1

I'm trying to get a handle on how you know if an expandable string will be properly expanded in a user's Path environment variable.

As there appears to be a lack of proper documentation on the MS website(these are the closest I can find; SE threads here and here also apply), my questions (and observations) can be categorized as follows.

  1. Variable Type

    • MS documents that it can be a String, Expandable String, or Multistring.
    • Default appears to be standard String.
    • If multistring, only the first string is recognized.
    • My system seem to periodically revert to a standard string after expanding variables first (with fixed values) from an expandable string.
    • I am unsure if it is Microsoft Updates or rogue installers that are changing the type back to standard String.
  2. Environment variable expansion layers

    • How many layers of variable expansion can I rely on? This SE thread seems to indicate that it's unpredictable.
      • Right now I have Path=%A_ProPath% where A_ProPath is another expandable string that begins %_SysPWin%;%_SysPIntel%;%_SysPVSdotNET%;%_SysPPy%;%_SysPPerl%;%_SysPChoc%;%_SysPJava%;%_SysPSQL%;.
      • If however, inside %_SysPIntel% I refer to %_Intel_SW% (C:\Program Files (x86)\IntelSWTools), that's not being expanded.
    • I was getting different results if I had a variable type set to expandable, but without any %var% references inside vs. just setting the variable type to standard string. It seems that references to standard strings are more often being expanded than references to expandable strings. Why is this?
  3. Expansion sequence of Expandable strings

    • Variable expansion is not recursive, so there don't appear to be any issue with cyclic references
    • Expansion seems only to proceed in alphabetical order, and only as a single pass (per level: system and then user).
    • Order that you add or edit variable values does not appear to matter
    • Variables are case-insensitive
    • Path in your System Variables is the same as %PATH% or %path% in a command prompt window).
    • I don't know if they are all converted to a single case before alphabetization.

      1. I believe I started doing _ to lead off my variable names because any values were alphabetically after Path weren't expanding in my Path, but this would suggest that you can't use %SystemRoot% or %WinDir% directly in a Path. Does this make any sense?

      2. Assuming environment variables are expanded in order of their alphabetic appearance, I further assume environment variables are case insensitive. But when sorting vs non-alphabetic characters, are environment variables evaluated as if any letters are lowercased and then compared by ascii value (e.g. perlre [0-9\- _] all occur before a-z)? or uppercased before ascii comparison (_ comes after the alphabet)?

      3. What is the set of acceptable characters used within variable names? Can ~[](), etc be used? ?*!.?

      4. If there's a System environment variable called PATH, and a user PATH, which is evaluated first? Can my user PATH make reference to system-level custom variables?

closed as too broad by DavidPostill Nov 9 '18 at 21:35

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • There are too many questions being asked in this single post. Please edit your question to focus on a single question, with perhaps any clearly related side-queries included. You may ask multiple questions on this site and can easily cross-reference them to provide context if you like. – Twisty Impersonator Nov 12 '18 at 23:35
  • (working on editing now. sorry for the incomplete edit) – mpag Nov 12 '18 at 23:39
  • It’s useful to do your editing offline (e.g., in a text editor or word processor) and then post it as a single edit when you’re done. (IMO, it’s still unclear and too broad.) – Scott Nov 13 '18 at 1:57