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.

On Unix operative systems I can start a process with additional environment variables like this:

$ DEBUG=1 VERBOSE=3 python myscript.py

Does the Windows CMD have an equivalent for this? I'm stuck developing on a Windows computer and I want to test release-behaviour without having to build the project or permanently change the env variables in my CMD session.

share|improve this question

2 Answers 2

The closest thing you can get is the SET command. This is not a permanent command, and will revert when you open a new CMD session.

Example: SET variable=string

http://ss64.com/nt/set.html

share|improve this answer
    
+1 That's cool, but it's not really equivalent of the Unix example. I want to set environment variables for one process, but SET changes the environment for the console. –  Hubro Jan 31 '13 at 9:47

You'd need to wrap your command in a batch file and then use setlocal in it:

setlocal
Set DEBUG=1
Set VERBOSE=1
python myscript.py

Setlocal makes all variable definition/changes local to that batch file.

Edit: You may use setlocal/endlocal to localize a single command, or set of commands in batch, but it does not work outside of batch. Full description of setlocal/endlocal

share|improve this answer

Your Answer

 
discard

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.