Windows 10 Environment Variables: why does variable replacement not work?












2















On Windows 10 Pro:



I just downloaded and installed (i.e. unpacked) the latest Maven version into a directory in preparation of an upcoming development project. Then - as instructed - I defined me two environment variables:



M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0


But for some strange reason the former %-placeholder 'M2' is not processed, i.e. "set" just yields:



>set
...
M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0
...


I have OK-ed and closed the env-var dialog and the system settings dialog. I restarted a new cmd-shell, I even killed and restarted Windows Explorer (i.e. the desktop), which should definitely trigger a re-read and re-substitution of those variables, and then restarted cmd from that desktop again but M2 remains at the unsubstituted %M2_HOME%bin-value.



I also checked in the registry:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironmentM2 is defined as REG_EXPAND_SZ, so it should be evaluated and %-vars should be substituted, but obviously here they are not.



If I assign the very same value manually on the command line it is of course properly substituted as one would expect, but not by default via the env-var definition shown above.



So, what am I missing here? Why is this M2_HOME as part of the M2-value not properly substituted?



Edit: added this output on JosefZ's request:



C:Usersmmo>reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2*

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
M2 REG_EXPAND_SZ %M2_HOME%bin
M2_HOME REG_EXPAND_SZ %ProgramFiles%Apache Software Foundationapache-maven-3.6.0

End of search: 2 match(es) found.

C:Usersmmo>reg query HKCUEnvironment -v M2*

End of search: 0 match(es) found.

C:Usersmmo>









share|improve this question




















  • 2





    What about simply reordering the vars, when M2_HOME isn't set how could it be substituted in the first command?

    – LotPings
    Feb 5 at 18:53











  • Please show us output from reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2* as well as from reg query HKCUEnvironment -v M2* (copy&paste from a cmd window.)

    – JosefZ
    Feb 5 at 19:42











  • @JosefZ: I added the result to my initial question above as the formatting gets garbled in these comments.

    – mmo
    Feb 6 at 6:51








  • 2





    @LotPings: not possible - they are automatically ordered alphabetically by the env-var dialog. And the order DOES seem to be an issue! I defined me a few more examples that refer to other env-vars further down (TestX=%TestY%test3, TestY=%TestZ%test2, TestZ=%JAVA_HOME%test1) and those are NOT correctly resolved, to! If I revert the order things work. So - it's indeed the order! IMHO that's a bug but I doubt I can convince MS on that...

    – mmo
    Feb 6 at 7:05








  • 1





    @LotPings: Could you please make that into an answer? Then I could give you credits. One apparently can't mark a comment as accepted answer.

    – mmo
    Feb 6 at 7:23
















2















On Windows 10 Pro:



I just downloaded and installed (i.e. unpacked) the latest Maven version into a directory in preparation of an upcoming development project. Then - as instructed - I defined me two environment variables:



M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0


But for some strange reason the former %-placeholder 'M2' is not processed, i.e. "set" just yields:



>set
...
M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0
...


I have OK-ed and closed the env-var dialog and the system settings dialog. I restarted a new cmd-shell, I even killed and restarted Windows Explorer (i.e. the desktop), which should definitely trigger a re-read and re-substitution of those variables, and then restarted cmd from that desktop again but M2 remains at the unsubstituted %M2_HOME%bin-value.



I also checked in the registry:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironmentM2 is defined as REG_EXPAND_SZ, so it should be evaluated and %-vars should be substituted, but obviously here they are not.



If I assign the very same value manually on the command line it is of course properly substituted as one would expect, but not by default via the env-var definition shown above.



So, what am I missing here? Why is this M2_HOME as part of the M2-value not properly substituted?



Edit: added this output on JosefZ's request:



C:Usersmmo>reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2*

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
M2 REG_EXPAND_SZ %M2_HOME%bin
M2_HOME REG_EXPAND_SZ %ProgramFiles%Apache Software Foundationapache-maven-3.6.0

End of search: 2 match(es) found.

C:Usersmmo>reg query HKCUEnvironment -v M2*

End of search: 0 match(es) found.

C:Usersmmo>









share|improve this question




















  • 2





    What about simply reordering the vars, when M2_HOME isn't set how could it be substituted in the first command?

    – LotPings
    Feb 5 at 18:53











  • Please show us output from reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2* as well as from reg query HKCUEnvironment -v M2* (copy&paste from a cmd window.)

    – JosefZ
    Feb 5 at 19:42











  • @JosefZ: I added the result to my initial question above as the formatting gets garbled in these comments.

    – mmo
    Feb 6 at 6:51








  • 2





    @LotPings: not possible - they are automatically ordered alphabetically by the env-var dialog. And the order DOES seem to be an issue! I defined me a few more examples that refer to other env-vars further down (TestX=%TestY%test3, TestY=%TestZ%test2, TestZ=%JAVA_HOME%test1) and those are NOT correctly resolved, to! If I revert the order things work. So - it's indeed the order! IMHO that's a bug but I doubt I can convince MS on that...

    – mmo
    Feb 6 at 7:05








  • 1





    @LotPings: Could you please make that into an answer? Then I could give you credits. One apparently can't mark a comment as accepted answer.

    – mmo
    Feb 6 at 7:23














2












2








2








On Windows 10 Pro:



I just downloaded and installed (i.e. unpacked) the latest Maven version into a directory in preparation of an upcoming development project. Then - as instructed - I defined me two environment variables:



M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0


But for some strange reason the former %-placeholder 'M2' is not processed, i.e. "set" just yields:



>set
...
M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0
...


I have OK-ed and closed the env-var dialog and the system settings dialog. I restarted a new cmd-shell, I even killed and restarted Windows Explorer (i.e. the desktop), which should definitely trigger a re-read and re-substitution of those variables, and then restarted cmd from that desktop again but M2 remains at the unsubstituted %M2_HOME%bin-value.



I also checked in the registry:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironmentM2 is defined as REG_EXPAND_SZ, so it should be evaluated and %-vars should be substituted, but obviously here they are not.



If I assign the very same value manually on the command line it is of course properly substituted as one would expect, but not by default via the env-var definition shown above.



So, what am I missing here? Why is this M2_HOME as part of the M2-value not properly substituted?



Edit: added this output on JosefZ's request:



C:Usersmmo>reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2*

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
M2 REG_EXPAND_SZ %M2_HOME%bin
M2_HOME REG_EXPAND_SZ %ProgramFiles%Apache Software Foundationapache-maven-3.6.0

End of search: 2 match(es) found.

C:Usersmmo>reg query HKCUEnvironment -v M2*

End of search: 0 match(es) found.

C:Usersmmo>









share|improve this question
















On Windows 10 Pro:



I just downloaded and installed (i.e. unpacked) the latest Maven version into a directory in preparation of an upcoming development project. Then - as instructed - I defined me two environment variables:



M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0


But for some strange reason the former %-placeholder 'M2' is not processed, i.e. "set" just yields:



>set
...
M2=%M2_HOME%bin
M2_HOME=C:Program FilesApache Software Foundationapache-maven-3.6.0
...


I have OK-ed and closed the env-var dialog and the system settings dialog. I restarted a new cmd-shell, I even killed and restarted Windows Explorer (i.e. the desktop), which should definitely trigger a re-read and re-substitution of those variables, and then restarted cmd from that desktop again but M2 remains at the unsubstituted %M2_HOME%bin-value.



I also checked in the registry:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironmentM2 is defined as REG_EXPAND_SZ, so it should be evaluated and %-vars should be substituted, but obviously here they are not.



If I assign the very same value manually on the command line it is of course properly substituted as one would expect, but not by default via the env-var definition shown above.



So, what am I missing here? Why is this M2_HOME as part of the M2-value not properly substituted?



Edit: added this output on JosefZ's request:



C:Usersmmo>reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2*

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
M2 REG_EXPAND_SZ %M2_HOME%bin
M2_HOME REG_EXPAND_SZ %ProgramFiles%Apache Software Foundationapache-maven-3.6.0

End of search: 2 match(es) found.

C:Usersmmo>reg query HKCUEnvironment -v M2*

End of search: 0 match(es) found.

C:Usersmmo>






windows-10 cmd.exe environment-variables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 6 at 6:54







mmo

















asked Feb 5 at 17:45









mmommo

1193




1193








  • 2





    What about simply reordering the vars, when M2_HOME isn't set how could it be substituted in the first command?

    – LotPings
    Feb 5 at 18:53











  • Please show us output from reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2* as well as from reg query HKCUEnvironment -v M2* (copy&paste from a cmd window.)

    – JosefZ
    Feb 5 at 19:42











  • @JosefZ: I added the result to my initial question above as the formatting gets garbled in these comments.

    – mmo
    Feb 6 at 6:51








  • 2





    @LotPings: not possible - they are automatically ordered alphabetically by the env-var dialog. And the order DOES seem to be an issue! I defined me a few more examples that refer to other env-vars further down (TestX=%TestY%test3, TestY=%TestZ%test2, TestZ=%JAVA_HOME%test1) and those are NOT correctly resolved, to! If I revert the order things work. So - it's indeed the order! IMHO that's a bug but I doubt I can convince MS on that...

    – mmo
    Feb 6 at 7:05








  • 1





    @LotPings: Could you please make that into an answer? Then I could give you credits. One apparently can't mark a comment as accepted answer.

    – mmo
    Feb 6 at 7:23














  • 2





    What about simply reordering the vars, when M2_HOME isn't set how could it be substituted in the first command?

    – LotPings
    Feb 5 at 18:53











  • Please show us output from reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2* as well as from reg query HKCUEnvironment -v M2* (copy&paste from a cmd window.)

    – JosefZ
    Feb 5 at 19:42











  • @JosefZ: I added the result to my initial question above as the formatting gets garbled in these comments.

    – mmo
    Feb 6 at 6:51








  • 2





    @LotPings: not possible - they are automatically ordered alphabetically by the env-var dialog. And the order DOES seem to be an issue! I defined me a few more examples that refer to other env-vars further down (TestX=%TestY%test3, TestY=%TestZ%test2, TestZ=%JAVA_HOME%test1) and those are NOT correctly resolved, to! If I revert the order things work. So - it's indeed the order! IMHO that's a bug but I doubt I can convince MS on that...

    – mmo
    Feb 6 at 7:05








  • 1





    @LotPings: Could you please make that into an answer? Then I could give you credits. One apparently can't mark a comment as accepted answer.

    – mmo
    Feb 6 at 7:23








2




2





What about simply reordering the vars, when M2_HOME isn't set how could it be substituted in the first command?

– LotPings
Feb 5 at 18:53





What about simply reordering the vars, when M2_HOME isn't set how could it be substituted in the first command?

– LotPings
Feb 5 at 18:53













Please show us output from reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2* as well as from reg query HKCUEnvironment -v M2* (copy&paste from a cmd window.)

– JosefZ
Feb 5 at 19:42





Please show us output from reg query "HKLMSYSTEMCurrentControlSetControlSession ManagerEnvironment" -v M2* as well as from reg query HKCUEnvironment -v M2* (copy&paste from a cmd window.)

– JosefZ
Feb 5 at 19:42













@JosefZ: I added the result to my initial question above as the formatting gets garbled in these comments.

– mmo
Feb 6 at 6:51







@JosefZ: I added the result to my initial question above as the formatting gets garbled in these comments.

– mmo
Feb 6 at 6:51






2




2





@LotPings: not possible - they are automatically ordered alphabetically by the env-var dialog. And the order DOES seem to be an issue! I defined me a few more examples that refer to other env-vars further down (TestX=%TestY%test3, TestY=%TestZ%test2, TestZ=%JAVA_HOME%test1) and those are NOT correctly resolved, to! If I revert the order things work. So - it's indeed the order! IMHO that's a bug but I doubt I can convince MS on that...

– mmo
Feb 6 at 7:05







@LotPings: not possible - they are automatically ordered alphabetically by the env-var dialog. And the order DOES seem to be an issue! I defined me a few more examples that refer to other env-vars further down (TestX=%TestY%test3, TestY=%TestZ%test2, TestZ=%JAVA_HOME%test1) and those are NOT correctly resolved, to! If I revert the order things work. So - it's indeed the order! IMHO that's a bug but I doubt I can convince MS on that...

– mmo
Feb 6 at 7:05






1




1





@LotPings: Could you please make that into an answer? Then I could give you credits. One apparently can't mark a comment as accepted answer.

– mmo
Feb 6 at 7:23





@LotPings: Could you please make that into an answer? Then I could give you credits. One apparently can't mark a comment as accepted answer.

– mmo
Feb 6 at 7:23










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1402341%2fwindows-10-environment-variables-why-does-variable-replacement-not-work%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1402341%2fwindows-10-environment-variables-why-does-variable-replacement-not-work%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕