I have a program written in Visual Studio 6.0 using C++. The program should run until it receives a message to switch, then it should shut itself down, wait a few seconds, and then start up its sister program. Currently if I open the first program and close it manually, then run the sister program manually (double-clicking on it) everything works fine. I am trying to make it simpler for the user though and use a script that will run to handle this action when a special message is received.
Currently the flow of the program is for the main program to shut itself almost all the way down before it opens a VBScript file that will loop, waiting for the main program to close.
The main program then finishes closing itself. When the main is closed the vbs file will then wait 30 seconds and then run the sister program. The problem is that when I use ShellExecute to run the vbs file it seems to create a new thread. When MAIN closes and the sister program attempts to open I run into numerous errors with memory and inabilty to acess things that should have been cleaned up and freed when MAIN shut down (They share many resources). But if I run the script on my own from outside of my main program then it works fine... it is only if I call it from main that I receive the problem.
Anyone have any ideas /sample code on how I can run this vbs script from my program but not have this thread attaching back to the parent program? Not much to it but I included the code on how I call ShellExecute.
HINSTANCE nResult = ShellExecute(NULL, NULL, _T("C:\\Projects\\EMMT\\Software\\Scripts\\Switch_Over.vbs"), _T("1"), NULL, SW_HIDE);
if( (int)nResult == ERROR_FILE_NOT_FOUND)