I did search for an answer before posting this question but I couldn't find anything.
The problem is, I have a CMD shell from which different applications are being launched. What I want is to execute a bat files which can modify the current cmd environment.
In our current setup, we are using call to launch the batch file but that environment doesn't get updated in the callers cmd environment. Is there a command which runs the Batch in the current cmd shell?
"The batch file has simple set and setx. When the batch file is executed from the command prompt it opens a new instance and run the bat. So the env changes does not get set on the main cmd."
Both
set
andsetx
do not take effect in the command prompt that runs the batch file.set
applies to the current command prompt only (this is the new command prompt belonging to the batch file not the one that runs the batch file). These changes are lost when the batch file terminates.setx
only affects new command prompts (not those that are already open like the one that is used to run the batch file. You will only see thse changes if you start a completely new command prompt.What you need to do is have a single batch file that uses
set
and also launches your applications.You could start with something like How to Use a Batch File to Create a Command Prompt Menu to Execute Commands and add the appropriate
set
commands just before you call each application.Source Display, set, or remove CMD environment variables