0

When I create a scheduled task, I do so via command line:

schtasks.exe /Create /TN "startup-script" /TR "C:\startup.bat" /RU taskuser 
    /RP taskpasswd /SC ONLOGON

The idea is that this task run forever. The batch opens a java process that is never meant to end.

I've used ONLOGON, as the machine auto-logs in as taskuser.

All this works fine, for about 72 hours, after which the Duration flag kicks in and ends the process. Windows XP doesn't have the /DU flag on command line - is there an alternative method to creating a task that is meant to run from a system startup (doesn't even require logon) and runs forever, without touching a GUI?

Mike Fiedler
  • 2,162
  • 1
  • 17
  • 34

2 Answers2

2

Are you tied to Schtasks.exe?

You can use a cron type process launcher (there are many - here are a couple):

Another possibility is to use srvany.exe from the 2k3 resource kit (runs on XP) and turn startup.bat into a service which will be running at the point netlogon starts.

Rob

RobW
  • 2,806
  • 1
  • 19
  • 22
  • +1 Run it as a Service. – AndyN Jan 10 '11 at 17:23
  • Java programs are quite tough to run as a service, in my experience and reading. – mfinni Jan 10 '11 at 17:34
  • Rob, Andy - like mfinni said - running a java app as a service - any thoughts? – Mike Fiedler Jan 10 '11 at 18:41
  • If you want a service wrapper for Java, here's a commercial product that I've used. As in, I've used commercial software that used this wrapper. It works, not much else to say about it. http://wrapper.tanukisoftware.com/doc/english/download.jsp – mfinni Jan 10 '11 at 18:59
  • Mmmm. I have no direct experience either way with java app to service. But I am an optimistic that an app that is not using relative paths, and that requires no occasional user input should be able to become a service. Conceptually, the Windows task scheduler or a cron service, are wrappers for the process being launched - they provide environment, authentication, etc, and may be a way of avoiding the problems that mfinni is referring to. – RobW Jan 10 '11 at 22:09
  • The problem with simply service-izing a BAT script that runs a java program is that the BAT script (and thus Java) won't properly work with restart/shutdown signals sent to/by the service. – mfinni Jan 10 '11 at 23:24
1

If you want a service wrapper for Java, here's a commercial product that I've used. As in, I've used commercial software that used this wrapper. It works, not much else to say about it. http://wrapper.tanukisoftware.com/doc/english/download.jsp

mfinni
  • 36,144
  • 4
  • 53
  • 86