Under Windows 8 I'm starting an external program but it get stuck as a background process waiting for svchost.exe to return. If I start the same application manually (double click) it starts just fine. If I run the same code under Windows 7, it works just fine.
I have mainly tried 3 ways of executing the application:
ShellExecute(NULL,L"open","MyApp.exe",NULL,NULL,SW_SHOWNORMAL);
This returns ok but the application freeze waiting for svchost.exe. Then I tried the Extended version.
SHELLEXECUTEINFO ShExecInfo;
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = Application->MainFormHandle;
ShExecInfo.lpVerb = L"open";
ShExecInfo.lpFile = L"MyApp.exe"
ShExecInfo.lpParameters = NULL;
ShExecInfo.lpDirectory = L"MyWorkDir";
ShExecInfo.nShow = SW_SHOWNORMAL;
ShExecInfo.hInstApp = NULL;
res = ShellExecuteEx(&ShExecInfo);
This also returns ok and I hInstApp is set, but still freeze as before. Then I tried CreateProcess().
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
res = CreateProcess(L"MyApp.exe",NULL,NULL,NULL,false,0,NULL,L"MyWorkDir",&si,&pi);
This also returns ok and the PROCESS_INFORMATION is filled in correctly, but still it freeze. RAD Studio shows a debug message when I create the process:
Application "\??\C:\Windows\Program Files (x86)\ ... MyApp.exe" found in cache
Application "\??\C:\Windows\Program Files (x86)\ ... MyApp.exe" cache bypassed reason 0x86
In Windows 8 Task manager I can see that the Process is waiting on svchost.exe to return.