I work on an app that calls another app via CreateProcess. I’m on Win7 64 bits. The called app is a console that receive data through a pipe. The calling code looks like this:
STARTUPINFOA si;
PROCESS_INFORMATION pi;
GetStartupInfoA(&si);
memset( &si, 0, sizeof(STARTUPINFOA) );
memset( &pi, 0, sizeof(pi) );
si.cb = sizeof(STARTUPINFOA);
char cmdline[MAX_PATH];
sprintf(cmdline,"\"%s\" %s",AppToCallName,PipeName);
BOOL bRet = CreateProcessA(NULL,cmdline,NULL,NULL,FALSE,CREATE_NEW_CONSOLE|CREATE_BREAKAWAY_FROM_JOB,NULL,NULL,&si,&pi);
On my computers (I tried on two), it works. On other ones, it returns (bRet=)FALSE then GetLastError() returns 5 which means ACCESS_DENIED.
I cannot figure out where is the problem. And the bad thing is that it works for me so I can’t debug it!
My setup is:
-
Win7 Pro 64 bits SP1
-
VStudio 2005 SP1
-
(Compiler used: Intel C++ 9.1
I will be glad to furnish more setup info if you need it!
Any idea?
CreateProcessuses the same permissions as the calling process it also will terminate the process if it has not initialized properly so you should wait and verify the process launched even ifCreateProcessreturns success. However your access denied issue is probably related to your calling process not having execute or write permissions on whatever application you were attempting to launch on the target machine.In addition to
GetLastErrorwhen the function succeeds checkGetExitCodeProcessas that will probably be your next problem.Also for reference: http://msdn.microsoft.com/en-us/library/ms682425(v=vs.85).aspx