process.start() not working when not in debug mode. Works fine when debugging

363 Views Asked by At

I have a pretty simple C# program that needs to silently uninstall an old product. So I set up a process and run it with the right parameters and when I step through the code it works fine every time. When I run it from the command line it fails every time. I'm capturing StandardOut and StandardError and StandardOut just contains the text:

This action is only valid for products that are currently installed.

If I then immediately run it in debug mode it works fine so it's clearly not true that the product isn't installed.

Here's the code:

process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = processToRun;
process.StartInfo.Arguments = args;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
File.WriteAllText("stdout.txt", output);
string err = process.StandardError.ReadToEnd();
File.WriteAllText("stderr.txt", err);
process.WaitForExit();

And here are the values of:

StartInfo.FileName = "C:\Program Files (x86)\InstallShield Installation Information{325FAC03-900A-4BB2-B45E-1D0EB4D414BE}\setup.exe"

StartInfo.args = /s /f1"C:\Users\User\CommonCustomActions\Uninstall 5.0.0-5.3.2\Uninstall 5.0.0-5.3.2\bin\Debug\Uninstall response files\5.2.1\UNINST-5.2.1.iss"

Any ideas?

p.s. The original installation was built as an InstallShield InstallScript MSI project which is why I need to pass the "response file"

0

There are 0 best solutions below