views:

39

answers:

2

I am starting an installer from my application and then synchronously waiting for it to complete.

Process installerProcess = Process.Start("TheProcessName");

// Must EnableRaisingEvents before calling synchronous method WaitForExit 
// according to MSDN documentation.
installerProcess.EnableRaisingEvents = true;

installerProcess.WaitForExit();

My application needs to know if this installer completed successfully or not. If the user cancelled it or it failed for any reason, I need to find out.

I tried the ExitCode property of the process thinking that '0' would signify success and all other codes would signify failure but it showed the same exit code for a successful or unsuccessful install so now I am stumped. Any ideas? Or is there a better way of doing this than I am currently doing it?

A: 

I believe the approach Windows uses for checking installer compatibility is to watch the number of keys under the Uninstall registry key. If this increases, chances are good that the install was a success. In your case you could probably look for just any relevant registry key installed by the particular installer you launch, but its uninstall key could be a good choice.

Michael Urman
Thanks Michael, that's an interesting approach. I'll look into this.
Peter Kelly
+1  A: 

What type of InstallShield project are you using? MSI or script driven? I've always had msixec and setup.exe return meaningful exit codes. Something is not right here.

Christopher Painter