In Linux you can do this:
$ php blah.php > some.log &
blah.php in the background. This is the same as Ctrl+z then the
Is there an equivalent of either/both for the Windows Command Prompt?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Windows does have a similar functionality to Linux's
&, to launch processes such that they don't take over your console. Instead of a command-line flag, though, it's a command prefix.
Simply run your command with
start in front of it, as such:
C:\> start myprog.exe
It also works with commands, not just executables:
C:\> start dir
This will start a new console window and run the command inside it.
If you don't want to have a new console window come up when running the command, use the
/B switch, like this:
C:\> start /B myprog.exe
There are several other options you can specify to configure how to run the command. You can figure them out by reading the help for
start by using
This can run a file in the background from the command prompt or a batch file
@Echo off Echo Set WshShell = CreateObject("WScript.Shell") >>%temp%\ghost.vbs Echo WshShell.Run chr(34) ^& "MyFile" ^& Chr(34), 0 >>%temp%\ghost.vbs Echo Set WshShell = Nothing >>%temp%\ghost.vbs start %temp%\ghost.vbs timeout /t 1 >nul del %temp%\ghost.vbs
MyFile with the file you wish to run in the background.
Just for fun I tried putting "ssh -N -f -l" into Windows Powershell / command prompt, and it does go into the background, but then you have to kill the window to get rid of it. I would like to have a powershell script that runs "ssh -N -f -l" to establish a port tunnel, but then I wouldn't be able to put any new lines in the script after the ssh line, it just hangs there and executes the remaining lines only if ssh fails. I wish there was a powershell equivalent of Linux's ampersand so I could go to the next line and perhaps run mstsc.exe .