I am looking to set environment variables like PATH, INCLUDE, LIB. For example, I would like to accomplish the following set of actions:
Execute the Microsoft compiler batch file – vcvarsall.bat (to set up the PATH, INCLUDE, LIB variables)
cl /c a.cpp (compile program)
cl /link a.obj (link program)
a.exe (execute program)
Currently, I am enclosing all the above 4 steps in a batch file and using “Execute Program from Automise” to launch the application. However, I have about 500 files to go through the above steps with different options in steps 1, 2, 3. This workaround of enclosing all the options in one batch file and “executing program” is becoming very inconvenient.
Is there any way to modify the Environment variables – PATH, INCLUDE, LIB using the Automise actions/scripts such that the modified values live over the life time of the project? I am able to manage steps 2, 3 from the supported Automise actions.
I wanted to include the content of my email to you on the forums to help others who may be trying to find a solution to this issue.
Automise runs the batch file by spawning a new process, so the variables die with the process (this is due to Windows and is outside of our control). The best way to use them within Automise therefore is to simply set the values of the variables once the control flow returns to Automise.
By running the batch file via a "Run DOS command" action instead of an "Execute program" action, you can include a "&&" to run either another batch file or an Automise Project with the same variables. For example, the DOS command for running a second Automise project would be: IntelCompiler.bat && "C:\Program Files (x86)\Automise 2\ATCMD.exe \pWriteVars.atz2")
This second batch file or Automise project will have the same variable values so can write these to an .INI file. Once the batch file is completed, Automise can then read the variables from the INI file. Depending on how many variables you need to set, this should not be too difficult to achieve in an Automise project. You can use the "Save Variables to INI" and "Load Variables from INI" actions, alternatively use the "Write to INI File" and "Read INI file" actions.