6

In linux we just need to append a & and that's all.

What for windows?

vps
  • 1,187
  • 3
  • 12
  • 12

5 Answers5

7
start /min cmd /c mycommand

If you want to run other jobs in the same shell you have to use powershell background jobs

If you want to hide the command window save a vbscript file with the following code(replacing the commands as needed) :

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "C:\mycommand_path\mycommand and args" & Chr(34), 0
Set WshShell = Nothing

create a shortcut to this file and run this from the shell directly by double clicking it. It sounds like what you are really after is job control. Install the subsystem for unix to get the bash or ksh prompt and execute it from there if you want job control however it would not suprise me if running it as a background job causes issues. You will probably want to run it as a background process instead.

the-wabbit
  • 40,319
  • 13
  • 105
  • 169
Jim B
  • 23,938
  • 4
  • 35
  • 58
  • I tried this but not work:`start /min cmd php file.php args /c`,`file.php` is not run – vps Mar 12 '10 at 18:56
  • I wouldn't consider this the equivalent of running a process in the background. – Warner Mar 12 '10 at 18:57
  • @vps try start /min "cmd /c php file.php args" – Jim B Mar 12 '10 at 19:05
  • 1
    This is minimize,not background – vps Mar 12 '10 at 19:20
  • @Warner, it's a process in the background, what's your definition of background process? If you want job control (which is a posix/unix concept) that is a different concept and you would want to enable the posix windows shell. Powershell is the only job control enabled shell other than the posix shell that microsoft makes. – Jim B Mar 12 '10 at 20:00
  • @vps that's the background (if it's not in the foreground its in the background), see the edits if you want to hide the command window as well – Jim B Mar 12 '10 at 22:57
  • Powershell background jobs would be the best way to do this in windows. – Greg Bray Mar 13 '10 at 20:30
  • The process forked outside of the user interface. – Warner Mar 15 '10 at 13:35
5

This is called job control in the *nix world. Job control is a required feature of a POSIX shell.

For Windows, I found this post about some equivalents..

Kyle Brandt
  • 82,107
  • 71
  • 302
  • 444
  • Job control does not exist on Windows. Quote from your link: "If I want true job control, I just install Cygwin." – ceving Sep 09 '15 at 12:36
1

There is no equivalent. You could install cygwin and do the same thing. Or you could make a service that runs your application : srvany or other tools will do this for you. Keep in mind that not all Windows applications will properly run in these ways.

mfinni
  • 35,711
  • 3
  • 50
  • 86
1

You can use HStart for this purpose, it allow to run a command in background .

aleroot
  • 3,160
  • 5
  • 28
  • 37
  • Nobody has asked how to hide a job. The question was only how to run a job in the background. And normally this implies the requirement, that the job is not hidden, because if it would be hidden, it will not be possible to see any error messages. – ceving Sep 09 '15 at 12:39
0

Nobody has mentioned start /b:

C:\Users\dandv>help start
Starts a separate window to run a specified program or command.

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
      [command/program] [parameters]

    "title"     Title to display in window title bar.
    path        Starting directory.
    B           Start application without creating a new window. The
                application has ^C handling ignored. Unless the application
                enables ^C processing, ^Break is the only way to interrupt
                the application.
Dan Dascalescu
  • 590
  • 1
  • 9
  • 21