PDA

View Full Version : CreateProcess wupdate (Web Update) silently fails



markwa
03-30-2007, 11:24 PM
My C++ app's call to CreateProcess for wupdate is silently failing. I'm at a loss for how trouble-shoot this.



CString strWupdatePath;
GetMNApp()->GetNotationDirectory(strWupdatePath);
strWupdatePath += "\\wupdate.exe";

STARTUPINFO startupInfo;
ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
startupInfo.dwFlags = STARTF_USESHOWWINDOW;
startupInfo.wShowWindow = SW_SHOW;

PROCESS_INFORMATION processInformation;
ZeroMemory(&processInformation, sizeof(processInformation));

if (!CreateProcess(strWupdatePath,
NULL,
NULL, // lpProcessAttributes
NULL, // lpThreadAttributes,
FALSE, // bInheritHandles
0, // dwCreationFlags
NULL, // lpEnvironment
NULL, // lpCurrentDirectory
&startupInfo,
&processInformation))
{
AfxMessageBox("Could not start the automatic update.");
}
CreateProcess returns TRUE, but the first step of the wupdate u/i is not displayed.

If I play a trick, and rename wupdate.exe in the setup directory, and then put in its place another app (I used Windows mplayer2.exe), renaming mplayer2.exe to wupdate.exe, then my app correctly launches the substituted app. So, it seems that the CreateProcess coding is basically correct.

Also, if I run wupdate.exe stand-alone, then it works correctly.

So, in summary, wupdate.exe works stand-alone, and my app can successfully launch some other app substituted for wupdate.exe, but when my app tries to launch wupdate.exe, nothing happens, yet there is no failure return for the CreateProcess call.

Also, the Task Manager doesn't show wupdate.exe running as a process.

So, where do I go from here to trouble-shoot the problem? This is probably just a generic programming question about CreateProcess. Perhaps I need to add some special security options in the CreateProcess call. But I can find any other clues to know where I should go fishing next.

Has anyone been here before, having trouble launching wupdate via CreateProcess from a C/C++ app? (I'm using VC6, but that's probably irrelevant.)

Cheers
-- Mark

Unregistered
03-31-2007, 03:24 AM
We are using CreateProcess to execute wupdate.exe and it works without any problem.

Tom

markwa
03-31-2007, 02:09 PM
Hello Tom,

Did you use any CreateProcess parameters other than the vanilla ones I used, as shown above?

Thanks!

Cheers
-- Mark

markwa
04-02-2007, 04:30 PM
I found the problem. I was confused about the first two parameters of CreateProcess.

Assuming that wupdate.exe is in the same directory as your app.exe that is calling wupdate.exe, the corrected code is:



CreateProcess(NULL,
"wupdate.exe",
NULL, // lpProcessAttributes
NULL, // lpThreadAttributes,
FALSE, // bInheritHandles
0, // dwCreationFlags
NULL, // lpEnvironment
NULL, // lpCurrentDirectory
&startupInfo,
&processInformation)
Cheers
-- Mark