There is any way to run processes in the background in Windows? nohup equivalent for windows

nohup runs a process in the background. There is any equivalent for Windows?


You can use the start command to run a process in the background of the command window.

command1
command2
start command3
command4

command2 waits until command1 finish but command4 don't wait that command3 finishes.

and if you need to run independently of the user logged on, you need to start the process as a service and you can use anysrv.exe


You might want to look at windows services. There are some tools you can download to host any process as a windows service. This causes the process to load in the background at windows startup, so provided it doesn't require user interaction you should be able to host it like this.

Windows Server 2003 Resource Kit

The tool you're after is called srvany.exe.


The only way, in Windows, that you can have a process started by a user continue running after logoff (i.e. what "nohup" does) is to start it either through a "scheduled task" or as a Windows service. When the user logs off all processes in their logon session will be killed.

If you're game to try the "Scheduled Tasks" method, you'll want to know how to create them programmatically. The Win32_ScheduledJob WMI class can do it. Documentation is provided in detail here: http://www.microsoft.com/technet/scriptcenter/guide/sas_man_rsxs.mspx?mfr=true Basically, you're looking at doing (shamelessly stolen from Microsoft):

Set objService = GetObject("winmgmts:\\.")
Set objNewJob = objService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create("Program-to-execute.exe", "ugly-formatted-time-string-per-Microsoft-docs",True ,1 OR 4 OR 16, , ,JobID)
If Err.Number = 0 Then
 Wscript.Echo "New Job ID: " & JobID
Else
 Wscript.Echo "An error occurred: " & errJobCreated
End If

To grant "joe user" the ability to create scheduled tasks, you'll have to modify the permission on the %SystemRoot%\Tasks folder. See here for some info on that front: http://technet.microsoft.com/en-us/library/cc785125(WS.10).aspx