Next, I store the CurrentPID into an environment variable;
From my .EXE, I obtain the value of environment variable _CurrentPID, then use the TCC SETP command to set an environment variable in TCC;
FUNCTION PBMAIN () AS LONG
DIM TCCPID AS STRING
DIM Command2Run AS STRING
DIM TCCRT AS STRING
Command2Run=TCCRT + " /C setp " + TCCPID + " FromEXE=Test"
When the .EXE is finished running, I have a new environment variable, FromEXE, with the value Test.
There are other methods to accomplish this, but this works best for me.
You'll save a lot of work by putting the string result into a file (easy) instead of an environment variable in the parent process (hard). The batch file can refer to the first line of the file as easily as it can refer to an environment variable ... %@line[filename,0].
If your EXE can call Win32 API functions, you could use the registry instead of a file. With RegCreateKeyEx and RegSetValueEx you can set a variable (my_var) in "HKCU\Volatile Environment". Your batch file can get the value of that variable with %@regquery["HKCU\Volatile Environment\my_var"].