scripting - How can I make a Windows batch-file which changes an environment variable? -


Is it possible to create a batch file that can make changes in an continuously environment variable?

For example, my installer.bat script copies some files in the computer's file system to random location . I would like to add that place to the path environment variable so that the programs can be run in the current session.

FYI - I am setting the changes very often: I want to do a fresh installation every time I run the program. In addition, I do not want to write more pre-installed copies of the program in case of execution of any other (old) frequency.

I should be able to do something like this:

  rim install_and_run.bat install.bat myapplication.exe  

Unfortunately This does not work, because install.bat main-scripts do not work. Myapplication.exe is never called. Next I tried:

  cmd / c install.bat myapplication.exe  

Unfortunately this does not work because it means install.bat Opening a completely separate cmd.exe means that when the script ends, none of the environmental variables remain because cmd.exe also ends.

There should be a way to create a batch-file that changes the environment variable

Any suggestions?

In your case, what do you want

  rim install_and_run Bat call install.bat myapplication.exe  

This is to call install.bat to use call Will come back to install_and_run.bat .

I think that you do not understand that the environment variable is per-process your batch file is running at a frequency of cmd.exe, and in that case an environment When you wrote CMD / C>, you were making a new example of CMD.XA, which has its own environment. Then the new example of install.bat CMD.XA was making "continuous" changes in the environment.


Comments