This seems trivial, but the answer eluded me for a few days.
I have a Windows batch file that calls a C # program to perform an additional check that cannot be performed in a batch file. Upon completion of the check, I need to return the status and the string back to the calling shell.
Now the return value is trivial, and my C # console application just sets the return value (exit code if you want). And I thought the string would also be a piece of cake. I tried to define a new shell variable with:
Environment.SetEnvironmentVariable("ERR", "Some text");
This call should (and should) define a shell variable in the current process - this is the C # process itself that created the variable. The value is lost as soon as the C # application terminates, and the shell that created the C # application knows nothing about this variable. So ... Calling without much use ... Anyway ... If, maybe, if I created a child process from a C3 application, maybe it would inherit my variables.
The EnvironmentVariableTarget.Machine and EnvironmentVariableTarget.User objects to call SetEnvironmentVariable also do not solve the problem, since only the newly created process will receive these new values from the registry.
Therefore, the only working solution I can think of is:
- write to stdout
- write to file
- encodes extra meaning into the return value
, .
( )? , (, PATH)...
.