0

On Linux, I could do this just doing:

myprogram &

However on Windows... If I start a command like:

start /B myprogram.exe

It runs in the background, but if I close my command prompt, the myprogram.exe is not killed. How to make it be killed automatically when the command prompt is closed?

Related question:

  1. Windows - Run process on background after closing cmd
user
  • 388
  • 3
  • 7
  • 18
  • 2
    Use `cmd /c` command before it. – Biswapriyo Jul 29 '17 at 01:37
  • I tried `cmd /c npm run watch`, but the console still locked into the node process. Did you mean `cmd /c start /B npm run watch`? Update, I tried this last one and worked! What magic is this? – user Jul 29 '17 at 01:58
  • Possible duplicate of [What's the Bash equivalent of "cmd /c"](https://superuser.com/questions/860833/whats-the-bash-equivalent-of-cmd-c) – Vomit IT - Chunky Mess Style Jul 29 '17 at 03:14
  • 1
    `start` doesn't make the program "run in the background". It makes it run as a child of the desktop process. There are equivaments in Linux desktop environments (`kstart` for KDE, for instance). – xenoid Jul 29 '17 at 08:42
  • @user `start /b` command starts application without creating a new window. – Biswapriyo Jul 29 '17 at 10:29
  • But if the current window is closed, the application does not die. Which is the opposite on the linux `commmand &` which start the application, but if the window closes, the application closes also. – user Jul 29 '17 at 19:12
  • of course it cannot die, because as others has said multiple times, **`start /b` doesn't start the process in background** and just starts a process that doesn't belong to the current console – phuclv May 05 '19 at 08:10

0 Answers0