In linux you can use command & to run command on the background, the same will continue after the shell is offline. I was wondering is there something like that for windows…
-
2Good question, but should be asked at [SuperUser](http://superuser.com). As far as I know, there is no such facility. Windows uses Services for background tasks with no shell, but they have to be specially coded - you can't just run any command as a service. The closest you'd get would maybe be the `start` command, which starts a new shell. – paddy Jan 09 '14 at 21:12
-
1@paddy but if I use `start` it will stop running as soon as I get offline right? – Louis Jan 09 '14 at 21:15
-
2Yes, that's correct. processes started with `start` are terminated when you log out. So it's not suitable for long-running remote background jobs. – Anthony May 15 '15 at 11:17
-
1[Superuser has the answer](http://superuser.com/questions/198525/how-can-i-execute-a-windows-command-line-in-background), @paddy. – Dan Dascalescu Aug 16 '15 at 18:56
-
Your question contains an invalid assumption. Commands started with & will die with the shell. So in that sense `start /b` in Windows is the same as & in *nix. – Terrible Tadpole Apr 11 '23 at 00:59
9 Answers
I believe the command you are looking for is start /b *command*
For unix, nohup
represents 'no hangup', which is slightly different than a background job (which would be *command* &
. I believe that the above command should be similar to a background job for windows.

- 1,041
- 2
- 7
- 13
-
8question: start /b *command* will stop running as soon i logoff from the server right? and yes, sorry I is `command &` not `nohup` – Louis Jan 09 '14 at 21:19
-
1See this answer: http://stackoverflow.com/a/3382087/1751190 I believe so, but I'm not positive. I would test it myself, but I'm not near a windows computer right now. – Oeste Jan 09 '14 at 21:22
-
7Just as a confirmation: yes, the command WILL DIE if you log off (if you connected on the windows machine from a telnet to run the command). – msb Nov 05 '14 at 01:18
I'm assuming what you want to do is run a command without an interface (possibly automatically?). On windows there are a number of options for what you are looking for:
Best: write your program as a windows service. These will start when no one logs into the server. They let you select the user account (which can be different than your own) and they will restart if they fail. These run all the time so you can automate tasks at specific times or on a regular schedule from within them. For more information on how to write a windows service you can read a tutorial online such as (http://msdn.microsoft.com/en-us/library/zt39148a(v=vs.110).aspx).
Better: Start the command and hide the window. Assuming the command is a DOS command you can use a VB or C# script for this. See here for more information. An example is:
Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run("C:\yourbatch.bat"), 0, True
You are still going to have to start the command manually or write a task to start the command. This is one of the biggest down falls of this strategy.
- Worst: Start the command using the startup folder. This runs when a user logs into the computer
Hope that helps some!
-
1if you only have VS express then this is a way to create a windows service: http://www.codeproject.com/Articles/106742/Creating-a-simple-Windows-Service – Graham Jul 31 '14 at 12:39
-
Use the start
command with the /b
flag to run a command/application without opening a new window. For example, this runs dotnet run
in the background:
start /b dotnet run
You can pass parameters to the command/application too. For example, I'm starting 3 instances of this C# project, with parameter values of x
, y
, and z
:
To stop the program(s) running in the background: CTRL + BREAK
In my experience, this stops all of the background commands/programs you have started in that cmd
instance.
According to the Microsoft docs:
CTRL+C handling is ignored unless the application enables CTRL+C processing. Use CTRL+BREAK to interrupt the application.

- 1
- 1

- 9,922
- 3
- 44
- 62
You should also take a look at the at
command in Windows. It will launch a program at a certain time in the background which works in this case.
Another option is to use the nssm
service manager software. This will wrap whatever command you are running as a windows service.
UPDATE:
nssm
isn't very good. You should instead look at WinSW project. https://github.com/kohsuke/winsw

- 10,029
- 11
- 83
- 152
If you take 5 minutes to download visual studio and make a Console Application for this, your problem is solved.
using System;
using System.Linq;
using System.Diagnostics;
using System.IO;
namespace BgRunner
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting: " + String.Join(" ", args));
String arguments = String.Join(" ", args.Skip(1).ToArray());
String command = args[0];
Process p = new Process();
p.StartInfo = new ProcessStartInfo(command);
p.StartInfo.Arguments = arguments;
p.StartInfo.WorkingDirectory = Path.GetDirectoryName(command);
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.Start();
}
}
}
Examples of usage:
BgRunner.exe php/php-cgi -b 9999
BgRunner.exe redis/redis-server --port 3000
BgRunner.exe nginx/nginx

- 61
- 1
- 1
-
Probably not the sort answer the OP was hoping for, but publishing the source code deserves an upvote, so +1. – Binarus Dec 21 '21 at 11:48
-
well, this doesn't work for calc.exe https://i.stack.imgur.com/b5Aqh.png – barlop Jun 29 '22 at 03:20
-
also definitely flashes up a cmd prompt for a moment if i do (tested from win7), "start".."run".. `c:\users\user\abc\a.exe c:\users\user\abc\bb.bat` – barlop Jun 29 '22 at 03:31
-
Whoever downloads Visual Studio in 5 Minutes has better internet than my university. x) – monamona Jun 05 '23 at 14:01
It's unimaginable that after a decade that Windows still doesn't have a decent way to run commands in background.
start /B command
is the most given answer, but the command will be closed when the terminal closed.
Now, Windows 10 have a built-in(you have to install it mannually though) ssh server. you can run
ssh username@localhost "my_backgroud_command --params"
and then CTRL C, close the terminal, the command will continue to run in background.
This is the most decent way I have found so far. Although not decent enough, because you have to install and configure the ssh server first.

- 385
- 1
- 3
- 11
-
This is incorrect as far as I can tell. I just tried it on Windows 10 Pro where I ran `start /b notepad` and the Notepad process started, my `cmd` prompt was released and when I exited `cmd`, Notepad was still running. – Wayne Bloss Dec 10 '22 at 00:45
-
We are talking about "running commands in background". Notepad is a GUI application, I don't think it has anything to do with "running in background". – Gary Allen Mar 22 '23 at 09:20
-
Thanks for the clarification. To me "background" simply meant "detached", as in "not dependent on the parent process". – Wayne Bloss Mar 23 '23 at 19:42
To run a command in background on windows cmd Add prefix "start /B" with it. Below code run cmd1 in background.
start /B cmd1
To run multiple command parallelly on windows cmd, we can run using belowe command in cmd.
start /B cmd1 & start /B cmd2

- 31
- 4
An option I use frequently when I need to run a simple command, or set of commands, in the background and then log off, is to script the command(s) (BAT, CMD, PowerShell, et al. ... all work fine) and then execute the script using Windows native Task Scheduler. Jobs that are executed from the Task Scheduler do not die when you log off. Task Scheduler jobs can be configured to run as "hidden" i.e. the command prompt window will not be displayed. This script + Task Scheduler is a great alternative rather than developing an executable (e.g. yadda.exe) in your favorite development environment (e.g. Visual Studio) when the task at hand is simple and writing a console application to execute a simple command or two would be "overkill" i.e. more work than it's worth.
Just my two cents.
Cheers!

- 21
- 5
On a windows server here, use a title (in double brackets) , otherwise it will not "release" :
start "" "chrome.exe --parameters" && echo truc

- 148
- 8