Scheduled Task / Batch Code on Windows Server 2008 R2 SP1


  1. Posts : 19
    Windows XP Professional 32bit
       #1

    Scheduled Task / Batch Code on Windows Server 2008 R2 SP1


    I have some processes that I need to stop and restart each morning. In order to do this, I've created 2 scheduled tasks inside Task Scheduler:

    1.) Stop Foobar (Both Environments) - Triggers @ 6:45 AM Every Day
    2.) Start Foobar (Both Environments) - Triggers @ 6:48 AM Every Day

    Both tasks above make use of a respective *.BAT file to shut down and restart a task agent service. Unfortunately, the tasks have been bombing with "(0x5)" each morning. I'm not sure why, but I suspect it has something to do with the following code associated with each *.BAT file:

    stop.bat -
    Code:
    sc stop Foobar_f52d190a-0e84-4b3a-ab03-xsfc6450b845
    timeout 10
    sc stop Foobar_935feeac-b874-4cca-b8eb-xsf55881ffb2
    start.bat -
    Code:
    sc start Foobar_f52d190a-0e84-4b3a-ab03-xsfc6450b845
    timeout 10
    sc start Foobar_935feeac-b874-4cca-b8eb-xsf55881ffb2
    From what I understand of 0x5 codes, it's a "universal access denied" indicator. Is this true? If so, that would imply then that the service account responsible for executing the batch files isn't being permitted execution rights, right? Odd, because I've provided my username / password for the tasks to execute whether the user is logged on or not. From what I can see, it's storing the password, too... So what gives?

    Any insight is appreciated. And I added the "timeout 10" in order to give the tasks some buffer between each task. Maybe it needs more? I dunno...
      My Computer


  2. Posts : 19
    Windows XP Professional 32bit
    Thread Starter
       #2

    Turns out that the code works... The reason that I kept receiving the 0x5 result is due to the Scheduled Tasks not being executed with "highest privileges". Once this was set, everything ran like a charm.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:55.
Find Us