Temporarily set Environment variables with batch file
Asked Answered
H

1

8

I'd like temporarily set Environment variables like Catalina and Java_Home using a batch file, without making persistent changes.

Changes should be removed after the execution of a web-page.

There's a way to do it?

Hashimoto answered 5/11, 2015 at 11:9 Comment(4)
All variables you create in a batch file are volatile when using the SET command. They will all disappear after the batch file closes.Sisak
Well, after the command prompt that had the script running in it closes (just in case you ran the script from the command line instead of double-clicking it).Bothwell
setlocal is generally good practice as well. Changes to variables made within a setlocal session are forgotten when the script ends or endlocal is encountered. As a bonus, setlocal also preserves the current working directory.Basutoland
Yes. Setlocal/endlocal is a best practice in my bookSisak
S
7

In your file, at the top, use setlocal, when exiting the file, use endlocal.

Sholem answered 6/11, 2015 at 17:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.