1

I have a 'long-running' (run at startup, don't terminate) scheduled task set up to run on a server.

When I remote-desktop into the server using the same domain account as the scheduled task, and then log out of the server, the scheduled task is terminated.

Is there a way to avoid this happening?

I'm running this task under my domain account, so that it has the domain network-share permissions necessary to do its work.

3
  • Are you sure it's actually starting during startup? Do you by chance have Run only if logged on selected?
    – squillman
    Sep 1, 2011 at 13:53
  • No that's unchecked. Here's my workflow: I start the scheduled task manually while connected via remote desktop, then log off - the task stops working (I can tell because it's an HTTP server) and then when I connect again I can see it's not running. So in fact I haven't tested whether it starts when the server starts up. Possibly it would, but then it would always be stopped at the point I log off after connecting via remote desktop (I think I've seen that behaviour).
    – mackenir
    Sep 1, 2011 at 13:55
  • 1
    Possibly I need to suck it up and implement a windows service...
    – mackenir
    Sep 1, 2011 at 13:55

1 Answer 1

1

If you start the scheduled task manually then it's running within the context of your interactive session and thus will end when your interactive session ends (ie- logout). If it's getting run during startup, outside of an interactive session, then it shouldn't die when you log out of an interactive session. The fact that it's running successfully when you start it manually leads me to believe that it's NOT running successfully during startup, assuming the HTTP server is listening on a static port. If it was running at startup then you'd get a port in use exception when you start the process manually.

If this is for more of a long term solution then I would concur that you should bake it into a service.

2
  • 2
    "If it's getting run during startup, outside of an interactive session, then it shouldn't die when you log out of an interactive session." I need to test this, but from past experience I believe that even if a task is started outside an interactive session, if an interactive session is initiated with the same credentials, and then terminated, any tasks using the same credentials get killed off. I have used srvany.exe to make this app a poor man's windows service.
    – mackenir
    Sep 2, 2011 at 11:09
  • @mackenir: I can confirm this — just happened to me (: You can create multiple scheduled tasks (one at startup, one on login) and skip running one if the other already started, but it doesn't quite fill the gap after you've logged out and it killed the process.
    – jwd
    Oct 26, 2022 at 2:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .