Run a program as windows service or background job
nssm
Download nssm from http://nssm.cc/download and follow its usage to install custom program as service.
instsrv
- instsrv myProgram “c:\Program Files\Windows Resource Kits\Tools\srvany.exe”
- install_service.reg
1
2
3
4
5Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\myProgram\Parameters]
"AppDirectory"="d:\\bin\\myProgram"
"Application"="D:\\bin\\myProgram\\myProgram.exe"
"AppParameters"="-d -f d:\\MyWorkDir\\myProgram.ini" - sc config myProgram depend= Tcpip
net start myProgram
orsc start myProgram
java
1 | public class Run{ |
wscript
run.vbs
1 | Set WshShell = WScript.CreateObject("WScript.Shell") |
wscript run.vbs
at
if the session is closed such as remote desktop(mstsc), above program will be shutdown. But schedule job has no this problem at 17:50 wscript run.vbs
then delete this scheduled job
run nohup in cygwin
nohup wscript run.vbs 2>&1 &