I am trying to set the environment variables from batch file Session.bat which is generated from my C++ code storing some session related data to be set in enviroment variable some thing like this
Content of Session.bat
set SessionID_User=SAsdC123ASCascs123 echo %SessionID_User%
I tried to execute it from my C++ code using CreateProcess and system but none seems to work.
Although the batch file is executed from within the exe file without any exceptions when I try to see the environment variable that was intended to be set, I don't see it in the variables list I am printing on console using set I cannot see SessionID_User=SAsdC123ASCascs123
Below is the way I did the process
C:\Users\admin\Desktop>Session.exe C:\Users\admin\Desktop>set SessionID_User=SAsdC123ASCascs123 C:\Users\admin\Desktop>echo SAsdC123ASCascs123 SAsdC123ASCascs123 C:\Users\admin\Desktop> Why is the environment variable not getting set when I execute batch file from my exe but sets all good when executing batch file on it's own ?
Another Question is, Hows CreateProcess is different from system() in this usecase and in general