2

Is it possible to somehow interact with the Windows task scheduler through C#?

What I want to do, is our server needs an reboot sometimes but I don't want to just "hard reboot" it. Therefore it would be great if it were possible somehow to get the current status of our application in the task scheduler, to see if it's running.

If it's currently running, then my reboot application should wait X number of minutes checking again.

But first of all, could I get the status from my task?

KLIM8D
  • 582
  • 1
  • 8
  • 25

1 Answers1

2

Don't bother interacting with the task scheduler. Just open up remoting (or wcf) to the application and check if it is running that way. The task scheduler is only one of many possible ways it could start up, so that is really an unreliable way of checking to see if teh application is actually running. You want to know if your application is running, not if the task scheduler started it.

Talking about communication between applications (WCF)

Community
  • 1
  • 1
kemiller2002
  • 113,795
  • 27
  • 197
  • 251
  • Thanks for your reply. I am not really sure about this WCF. Would it be a bad idea using this, too check if the other application is runnning? Process.GetProcessesByName(processName); – KLIM8D Apr 09 '12 at 15:27
  • Off that top of my head, I can't see any problem with that. It sounds like you are on the right track either way. How you figure it's running, really isn't important. Like I said, you just don't want to pigeon hole yourself into only being able to check if a certain process started it. – kemiller2002 Apr 09 '12 at 15:37
  • The application I want to check if it's running can only be started by the task scheduler, but I can see your point. If the application were running and not started by the task schelduer, the running state wouldn't be accurate. I think i'll stick with the Process solution.:) – KLIM8D Apr 09 '12 at 15:49