Can I change the environment on a per-process basis on Windows (like on Unix)?

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


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