Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

I'm working on Windows 7. How can I permanently add a new path to the 'PATH' environment variable of the current user?

I tried to do so with wmic:

wmic ENVIRONMENT where "name='Path' and username='<%USERNAME%>'" set VariableValue="%Path%;%NEW_FOLDER_PATH%"

The result was:

No Instance(s) Available

And nothing was affected. However if I try with the following with Administrative privilege:

wmic ENVIRONMENT where "name='Path' and username='<system>'" set VariableValue="%Path%;%NEW_FOLDER_PATH%"

It could always succeed.

The NEW_FOLDER_PATH doesn't contain any blank spaces.

How could I resolve this problem?

share|improve this question

marked as duplicate by Karan, AthomSfere, tombull89, Excellll, Shekhar Jul 16 '13 at 13:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Do you want to do it programmatically or any way possible? –  Mario Jul 15 '13 at 9:55
    
@Mario: Any possible way is acceptable. I'm trying it in a Windows Batch file so this is my most desired way. –  rob Jul 15 '13 at 10:00

1 Answer 1

up vote 0 down vote accepted

Played around a bit, and it seems like it expects a domain/computer name together with the user name rather than brackets.

Try running this:

wmic ENVIRONMENT where "name='Path'"

This will return all results, essentially one per user. You'll notice that users use the full name, like Mario-PC\Mario rather than Mario or (what you've tried) <Mario>.

To fix your command line, you'll want to look for the name like that (note the escaped backslash!):

wmic ENVIRONMENT where "name='Path' and username='%USERDOMAIN%\\%USERNAME%'"
share|improve this answer
    
Great! That works! Yeah.. I should have thought of that earlier... –  rob Jul 15 '13 at 10:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.