Home » Questions » Computers [ Ask a new question ]

Setting multiple environment variables in a shell spawned via windows batch script

Setting multiple environment variables in a shell spawned via windows batch script

I have a batch file that spawns a shell with a modified path with the following command:

Asked by: Guest | Views: 57
Total answers/comments: 2
Guest [Entry]

"Simply add another variable on a new line using set as shown in your example. You will also want to remove the /K switch from the first line as execution will stop after that line.

set NEWVAR=SOMETHING

will create a new variable called NEWVAR with the value SOMETHING. If you wish to keep the same behavior and keep cmd open with the /K switch just put it at the end.

example:

set PATH=%PATH%;C:\Folder;
set NEWVAR=SOMETHING
echo %NEWVAR%"
Guest [Entry]

"summing up what others here posted, along with info gleaned from another post, here's what I saved into my internet_proxy_setup.bat file:
cmd /K ""set http_proxy=http://proxy.mycorp.com:1234&& set https_proxy=http://proxy.mycorp.com:1235&& echo In HTTPS Proxy Shell&& cd %~dp0""
where the cd %~dp0 just changes the shell to the same directory that the .bat file is stored in"