Create process
-
i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely
Arise Awake Stop Not Till ur Goal is Reached.
-
i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely
Arise Awake Stop Not Till ur Goal is Reached.
Create a Hint (That can be a simple file or an registry end) at the end of the execution of the batch file or the exe (if src is available). CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); //check for the hint here //if (completed) call ur message //this is the raw way of doing it. MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION);
-
Create a Hint (That can be a simple file or an registry end) at the end of the execution of the batch file or the exe (if src is available). CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); //check for the hint here //if (completed) call ur message //this is the raw way of doing it. MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION);
i dont know how to confirm that the process is completed since the process is to install a package
Arise Awake Stop Not Till ur Goal is Reached.
-
i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely
Arise Awake Stop Not Till ur Goal is Reached.
deeps_cute wrote:
i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened.
It sounds like the problem is the other exe is not waiting on the batch file? So if your program is waiting on the exe (which is not waiting on the batch file), your program is also not waiting on the batch file? Can you confirm this (e.g., run calc.exe and see if your program waits for it)?
deeps_cute wrote:
startup.hStdInput=NULL;
Since you've already called
ZeroMemory()
, this statement is pointless.deeps_cute wrote:
CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1)...
Why are you calling
GetBuffer()
? It is not necessary.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
i am calling a exe file from my program which in turn calling an batch. after executing this exe compltely only, i have to open a message box. but this is posting while the batch fle is opened. i used createprocess. CString ovpncheck1; ovpncheck1 = "C:\\Program Files\\OpenVPN\\bin\\sample.exe"; STARTUPINFO startup; ZeroMemory(&startup,sizeof(startup)); PROCESS_INFORMATION pInfo; ZeroMemory(&pInfo,sizeof(pInfo)); startup.cb=sizeof(startup); startup.dwFlags=STARTF_USESTDHANDLES; startup.hStdInput=NULL; CreateProcess(NULL,ovpncheck1.GetBuffer(ovpncheck1.GetLength() + 1), NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&startup,&pInfo); // PROCESS_INFORMATION WaitForSingleObject(pInfo.hProcess,INFINITE); MessageBox("Click YES to Configure EncryptaKey VPN 2","EncryptaKey VPN",MB_YESNO|MB_ICONQUESTION); how to open the messagebox only afetr executing the exe completely
Arise Awake Stop Not Till ur Goal is Reached.
PROCESS_INFORMATION prcInfo; STARTUPINFO startupInfo; memset(&prcInfo, 0, sizeof(PROCESS_INFORMATION) ); memset(&startupInfo, 0, sizeof(STARTUPINFO ) ); startupInfo.cb = sizeof (STARTUPINFO ); //DEBUG_ONLY_THIS_PROCESS BOOL blnStatus = CreateProcess("e:\\temp\\samp.bat", NULL, //CreateProcess("c:\\winnt\\system32\\calc.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &prcInfo); if (blnStatus ) { STILL_ACTIVE DWORD dwExitCode=0; BOOL blnExit = GetExitCodeProcess(prcInfo.hProcess, &dwExitCode); WaitForSingleObject(prcInfo.hProcess, INFINITE); blnExit = GetExitCodeProcess(prcInfo.hProcess, &dwExitCode); dwExitCode=0; AfxMessageBox("Hello Fin",MB_OK); CloseHandle(prcInfo.hProcess); //This is the code that i had tested working fine for me. // i tested in both the case in which the first one i called //the executable file directly, in the second time i called //using a batch file. The next statement of WaitForSingleObject is watiting actuall to end its process.