Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

c# - How can I start a process in the background?

I can't seem to find an answer on Google or here on StackOverflow.

How can I start a process in background (behind the active window)? Like, when the process starts, it will not interrupt the current application the user is using.

The process won't pop out in front of the current application, it will just start.

This is what I'm using:

Process.Start(Chrome.exe);

Chrome pops up in front of my application when it's started. How can I make it start in background?

I've also tried:

psi = new ProcessStartInfo ("Chrome.exe");
psi.UseShellExecute = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(psi);

But there's no difference at all from the previous one.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this:

 Process p = new Process();
        p.StartInfo = new ProcessStartInfo("Chrome.exe");
        p.StartInfo.WorkingDirectory = @"C:Program FilesChrome";
        p.StartInfo.CreateNoWindow = true;
        p.Start();

Also, if that doesn't work, try adding

p.StartInfo.UseShellExecute = false;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...