tags:

views:

155

answers:

2

I am developing an application that needs to use regini (because of legacy reasons) to insert something into the registry. I have been trying to do this in such a way the the user of the application is not aware of this. I have written the following code:

System.Diagnostics.ProcessStartInfo pi = new ProcessStartInfo();  

pi.FileName = @"c:\windows\system32\regini.exe";
pi.Arguments = name;
pi.WorkingDirectory = Utils.AppSettings.WorkingDirectory.ToString();    
pi.WindowStyle = ProcessWindowStyle.Hidden;
pi.RedirectStandardError = true;
pi.RedirectStandardOutput = true;
pi.UseShellExecute = false;  
Process p = new Process();
p.StartInfo = pi;
p.EnableRaisingEvents = true;
p.Start();

Unfortunately, I still see the 'command' window pop-up every time this code is executed. I was under the impression that

pi.WindowStyle = ProcessWindowStyle.Hidden;

would prevent that. How can I prevent regini from opening its own command window?

A: 

I found this bug report on the Microsoft Connect Feedback Site: System.Diagnostics.ProcessWindowStyle.Hidden shows window while executing

Maybe there is a hint of something you forgot.

splattne
Thanks, but the discussion in the link just focusses on the problem of reproducing the issue. Apparently they cannot.
Bernie
+1  A: 

Try to add this line:

pi.CreateNoWindow = true;
splattne