If you use a C # application from a dos script and want to use the variables set in the application after that from a script, I don’t know how to do this only for the context of this script from within C #, the other answers here show you for the machine itself, but I appreciate that you need something with a less constant area.
A workaround for metaprogramming can be as follows:
- Call C # application from DOS FOR loop
- In a C # application, output the SET console commands
- Use the for loop to execute application output
The calling DOS script will look like this:
FOR /F "tokens=* delims=" %%A IN ('MyApp.exe') DO ( %%A )
The console output from MyApp.exe should be in the form:
SET UserVariable1=UserValue1 SET UserVariable2=UserValue2
And then each of the output lines will be executed by the calling FOR loop, and then the variables will exist in the context of the calling script.
source share