tags:

views:

175

answers:

4
+1  A: 

Looks like a manifest or registry question judging from the error code. If you can't get the actual error message string for more details, you might try:

  • moving every possible manifest file (Microsoft.VC80.CRT.manifest and the like) into your exe's directory, to ensure accessibility
  • cleanly and completely uninstall/wipe out old versions of DLL you may have installer newer versions of (I suggest: uninstall EVERY version, clean the registry with a sweep-clean tool such as Norton's, reinstall the new stuff from scratch)
Alex Martelli
the problem is the exe runs fine by it self, only gets this issue when trying to restart it.
Lodle
If it *is* a manifest issue, you can use the event viewer to track it down.Then, if that doesn't help, run sxstrace from the commandline if you need further information. (Run it once without arguments to see its usage)But this doesn't look like a manifest issue to me.
Drew Hoskins
Just checked the event log and it seems one of the debugging dlls is having a side by side error. Strange as it works fine normally.
Lodle
+1  A: 

What happens if you run the process using system()? It gives you less control, but you'll be running it from the same context you're running in. Also, Try monitoring the launch of your second process using ProcMon, it might give you the hint you need about the source of the failure.

eran
+2  A: 

CreateProcess() is an arcane beast. I remember unfondly my first frustrations with it. You should look at the Microsoft CreateProcess Example and the CreateProcess Page. (those links likely have a short lifetime, Googling CreateProcess should work just as well).

I can see 3 problems in your code.

StartupInfo must have "cb" set to the structure size:

STARTUPINFO StartupInfo = {0};
StartupInfo.cb = sizeof(StartupInfo);

The second argument requires both the command and the arguments to form the command line. Your program will see "-wait" as argv[0] and ignore it or pay it no mind.

char command[512];
sprintf(command, "%s -wait", name);
BOOL res = CreateProcess(name, command, // and as you had before

You don't look at GetLastError() if CreateProcess() fails (by returning a zero). It may have helped you but I suspect it would just say "invalid argument" or somesuch. Hey, there's only 10 of them to check, don't be lazy :-)

Another bug I committed is not closing the hProcess and/or hThread handles return in PROCESS_INFORMATION when I was done. I did do hProcess, but not hThread.

George Phillips
Should of said that CreateProcess was returning 1 which means it was all ok.
Lodle
A: 

Ok worked it all out in the end.

The first time my exe ran it used the default paths and as such loaded vld (a leak detector dll) from the default path. However in the exe i modified the dll path to be the bin folder ([app]\bin) when i restarted the exe using CreateProcess it picked up on a different vld dll (this was my mistake) that had incorrect side by side linkage and it was only after looking at event viewer that i worked it out.

Thanks for all your help.

Lodle