here is th开发者_如何学运维e code I'm using:
string path = @"c:\temp\myprocess.exe";
ProcessStartInfo info = new ProcessStartInfo(path);
info.WorkingDirectory = path;
Process p = Process.Start(info);
I just need the executed process not to get the focus.
Thank you very much,
Adi BardaMaybe setting the WindowStyle property to Minimized can help.
If you don't need to show the process at all, try this:
string path = @"c:\temp\myprocess.exe";
ProcessStartInfo info = new ProcessStartInfo(path);
info.WorkingDirectory = path;
info.WindowStyle = ProcessWindowStyle.Hidden;
Or set WindowStyle to ProcessWindowStyle.Minimized if you want it visible but minimized, as Uwe Keim said.
can you do
myForm.Focus();
where myForm is the form on your main application
What i´ve done was to wait a little delay until the other application was succesfully loaded, then focus my application window.
//Test window
const string strCmdText = "/C cd C:\\sqlcipher";
Process.Start("CMD.exe", strCmdText);
//Delay
int liMilliseconds = 50;
Thread.Sleep(liMilliseconds);
//Code to bring window to front
this.WindowState = FormWindowState.Minimized;
this.Show();
this.WindowState = FormWindowState.Normal;
精彩评论