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
<pre> Windows 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" </pre>
- sc config myProgram depend= Tcpip
- net start myProgram or sc start myProgram
java
public class Run{
public static void main(String[] args) throws InterruptedException, IOException {
Process pr = Runtime.getRuntime().exec("D:\\bin\\myProgram\\myProgram.exe -d -f d:\\MyWorkDir\\myProgram.ini");
pr.waitFor();
}
}
javaw -cp . Run
wscript
run.vbs
<pre> Set WshShell = WScript.CreateObject("WScript.Shell") obj = WshShell.Run("plink.exe -load remotes_server -N", 0) set WshShell = Nothing </pre>
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 problemat 17:50 wscript run.vbs
then delete this scheduled job
run nohup in cygwin
nohup wscript run.vbs 2>&1 &