Is it possible to make a batch file which can make a persistent change to an environment variable?
For example my installer.bat script copies some files to a random location in the computer's file-system. I'd like to add that location to the PATH environment variable so that the programs can be run in the current session.
FYI - the stuff I am installing changes very frequently: I want to do a fresh install every single time I run the program. Also, I do not want to over-write other previously installed copies of the program just in case some other (older) instance is still executing.
I'd like to be able to do something like this:
rem install_and_run.bat
install.bat
myapplication.exe
Unfortunately this does not work, because the install.bat never "returns" to the main-script. myapplication.exe is never called. Next I tried:
cmd /C install.bat
myapplication.exe
Unfortunately this does not work because it means that install.bat is run in an entirely seperate cmd.exe shell. That means none of the environment variable changes persist once the script terminates because the cmd.exe also terminates.
There must be a way to make a batch-file which changes environment variables
Any suggestions?