Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I set my variable like this:

SET Ant="%HOMEDRIVE%%HOMEPATH%\Downloads\apache-ant-1.9.0-bin\apache-ant-1.9.0\bin"

:: Set Path variable  
setx PATH "%Ant%" /m

Then, the result for the path variable is :


As we can see, environnement variables are expanded.

I would like them not to be expanded to set my path variable like this:


Is there a way to not expand environnement variables ?

share|improve this question
And the question is? – Falcon Momot Jan 24 '14 at 10:15
@Falcon Momot I've edited the question to improve it – krisFR Jan 24 '14 at 12:51
up vote 2 down vote accepted

This do the trick on my Win7 :

SET Ant=^%HOMEDRIVE^%^%HOMEPATH^%\Downloads\apache-ant-1.9.0-bin\apache-ant-1.9.0\bin

setx PATH "%Ant%" /m

Let's check if everything is ok :

echo %Ant%

set | findstr Ant

Everything seems ok :)

To makes it work i had to :

  • Escape % characters using carets (^).
  • Remove double quotes.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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