I have a C# console executable started within a DOS command process.
I need to be able to execute DOS commands from the C# executable (specifically I need to be able to SET variables) and have the variables persist such that the rest of the DOS process can reference them.
ie:
Start DOS process
-> C# executes a SET command to set UserVariable
-> DOS process can ECHO %UserVariable%
Due to performance reasons I cannot write the set command to a dos script. In fact, I cannot have any file I/O at all.
Can anyone help?
If you are running a C# app from a dos script and wishing to use variables set in the app afterwards from the script, I don’t know how to do that for just the context of that script from within C#, the other answers here show you for the machine itself but I appreciate you need something with a less permanent scope.
A meta-programming workaround this could be to:
The calling DOS script would look like this:
The Console output from MyApp.exe would need to be in the form:
And then each of the output lines would be executed by the calling FOR loop and the variables would then exist in the context of the calling script.