Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Can someone tell me how to get the return code from a batch file that is called using shellExecuteEx().

C++
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = pathName;
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = newString;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);


Thanks,

Randy
Posted
Updated 4-Dec-14 8:55am
v2

1 solution

Windows provide the GetExitCodeProcess[^]. You may call it provided ShExecInfo.hInstance is properly assigned by ShellExecuteEx. If you need more control then you have to use the CreateProcess[^] function.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Dec-14 15:05pm    
5ed.
—SA
CPallini 4-Dec-14 15:12pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900