Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 501
Robert Malansangan Avatar asked Jul 25 '15 15:07

Robert Malansangan


People also ask

How do I run a process in the background?

If you know you want to run a command in the background, type an ampersand (&) after the command as shown in the following example. The number that follows is the process id. The command bigjob will now run in the background, and you can continue to type other commands.

Which command will make process to run in background?

Use bg to Send Running Commands to the Background Hitting Ctrl + Z stops the running process, and bg takes it to the background. You can view a list of all background tasks by typing jobs in the terminal.

How do I run a script in the background process?

Running shell command or script in background using nohup command. Another way you can run a command in the background is using the nohup command. The nohup command, short for no hang up, is a command that keeps a process running even after exiting the shell.

What does it mean to run a process in the background?

A background process is a computer process that runs behind the scenes (i.e., in the background) and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification.


1 Answers

Try this:

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

Also, if that doesn't work, try adding

p.StartInfo.UseShellExecute = false;
like image 179
Tayla Wilson Avatar answered Oct 21 '22 14:10

Tayla Wilson