Setting environment variables for Windows cmd temporarily, to run a program, in a single line?
You could run a batch file with a setlocal
or on cmd line start another cmd.exe which inherits the current environment but changes are volatile.
cmd /c "SET MYVAR=1&myprogram.exe"
Try this command:
set Foo=bar & abc.exe & set Foo=
This command does:
- Set
Foo
variable withbar
value. - Run
abc.exe
command. - Unset
Foo
variable by adding blank value.