locked
Windows 2008 R2 server Scheduled Task not working RRS feed

  • Question

  • I have a batch file that writes to a file, when I click it manually it works. However when I have it set in a scheduled task it will create the file but it will not write to the file.

     

    How can I fix this?


    • Edited by Ben___ Tuesday, October 11, 2011 9:14 PM
    Tuesday, October 11, 2011 9:13 PM

Answers

  • Hi,

     

    1.    Please try to make sure the Task Scheduler: Service is running.

     

    For details: run 'services.msc', Scroll down to the 'Task Scheduler' service, Check the 'Startup Type' column, The 'Startup Type' should be set to "Automatic", Check the 'Status' column.

     

    If the service is started, it will list 'Started' in the 'Status' column.

     

    2.    Please try to make sure Group Policy preventing the user to run the task.

    3.    Please try to make sure UAC has been disabled.

    4.    Please try to enabled the policy Inclusion list for moderate risk file types, and fill ‘.bat’ in the blank.

    For details: User Configuration -> Administrator Templates -> Windows Components -> Attachment Manager

     

    In addition, please try to refer this to troubleshoot.

     

    If the issue persist, please try to collect more information for further analyze:

     

    Event log

    ==============

    1. Click "Start", click “Run”, input "eventvwr" and press Enter.

    2. Expand the "Windows Logs" node on the left pane, right-click on "System" and click "Save All Events As"; in the pop-up window, click to choose the Desktop icon on the left frame, input "sys" in the "File name" blank, and then click save.

    3. Expand the “Applications and Services Logs”. Click the arrow next to Microsoft, and then Windows, and then TaskScheduler. Click Operational. Click "Save All Events As"; in the pop-up window, click to choose the Desktop icon on the left frame, input "policy" in the "File name" blank, and then click save.

    4. Locate the two saved log files on the Desktop and send them to us.

     

    GPMC.log

    ==================

    a.    On domain controller, click Start -> Run, type GPMC.MSC, it will load the GPMC console.

    b.    Right click on "Group Policy Result" and choose wizard to generate a report for the problematic computer and user account (please place appropriately). (Choose computer and select the proper user in the wizard)

    c.    Right click  the resulting group policy result and click the "Save Report…" => save report to save the report to a HTML file and send it to me.

     

    please contact me with my account: v-xchen@microsoft.com to get a workspace to upload the information.

     

    Hope this helps!

     

    • Edited by Elytis Cheng Wednesday, October 12, 2011 9:22 AM
    • Marked as answer by Elytis Cheng Wednesday, October 19, 2011 2:34 AM
    Wednesday, October 12, 2011 9:20 AM

All replies

  • Can we see the batch?

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Wednesday, October 12, 2011 12:39 AM
  • send us a screenshot of it..
    Regards, h9ck3r.
    Wednesday, October 12, 2011 6:43 AM
  • Hi,

     

    1.    Please try to make sure the Task Scheduler: Service is running.

     

    For details: run 'services.msc', Scroll down to the 'Task Scheduler' service, Check the 'Startup Type' column, The 'Startup Type' should be set to "Automatic", Check the 'Status' column.

     

    If the service is started, it will list 'Started' in the 'Status' column.

     

    2.    Please try to make sure Group Policy preventing the user to run the task.

    3.    Please try to make sure UAC has been disabled.

    4.    Please try to enabled the policy Inclusion list for moderate risk file types, and fill ‘.bat’ in the blank.

    For details: User Configuration -> Administrator Templates -> Windows Components -> Attachment Manager

     

    In addition, please try to refer this to troubleshoot.

     

    If the issue persist, please try to collect more information for further analyze:

     

    Event log

    ==============

    1. Click "Start", click “Run”, input "eventvwr" and press Enter.

    2. Expand the "Windows Logs" node on the left pane, right-click on "System" and click "Save All Events As"; in the pop-up window, click to choose the Desktop icon on the left frame, input "sys" in the "File name" blank, and then click save.

    3. Expand the “Applications and Services Logs”. Click the arrow next to Microsoft, and then Windows, and then TaskScheduler. Click Operational. Click "Save All Events As"; in the pop-up window, click to choose the Desktop icon on the left frame, input "policy" in the "File name" blank, and then click save.

    4. Locate the two saved log files on the Desktop and send them to us.

     

    GPMC.log

    ==================

    a.    On domain controller, click Start -> Run, type GPMC.MSC, it will load the GPMC console.

    b.    Right click on "Group Policy Result" and choose wizard to generate a report for the problematic computer and user account (please place appropriately). (Choose computer and select the proper user in the wizard)

    c.    Right click  the resulting group policy result and click the "Save Report…" => save report to save the report to a HTML file and send it to me.

     

    please contact me with my account: v-xchen@microsoft.com to get a workspace to upload the information.

     

    Hope this helps!

     

    • Edited by Elytis Cheng Wednesday, October 12, 2011 9:22 AM
    • Marked as answer by Elytis Cheng Wednesday, October 19, 2011 2:34 AM
    Wednesday, October 12, 2011 9:20 AM
  • Can we see the batch?

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]


    Yea here is the batch contents, like I said I don't think it's the batch file itself because when I manually double click the file it runs and does it's job (creating a file and backing up a database)  when I let the scheduled task do it, it only creates the files but does not write the database backup to it. 

     

    Here is the file contents:

     

    ECHO OFF
    REM  QBFC Project Options Begin
    REM  HasVersionInfo: No
    REM  Companyname:
    REM  Productname:
    REM  Filedescription:
    REM  Copyrights:
    REM  Trademarks:
    REM  Originalname:
    REM  Comments:
    REM  Productversion:  0. 0. 0. 0
    REM  Fileversion:  0. 0. 0. 0
    REM  Internalname:
    REM  Appicon:
    REM  QBFC Project Options End
    ECHO ON
    ECHO OFF
    ECHO OFF
    mysqldump.exe --no-create-info=FALSE --order-by-primary=FALSE --force=FALSE --no-data=FALSE --tz-utc=TRUE --flush-privileges=FALSE --compress=FALSE --replace=FALSE --host=localhost --insert-ignore=FALSE --extended-insert=TRUE --user=root --password=****** --quote-names=TRUE --hex-blob=FALSE --complete-insert=FALSE --add-locks=TRUE --port=3306 --disable-keys=TRUE --delayed-insert=FALSE --create-options=TRUE --delete-master-logs=FALSE --comments=TRUE --default-character-set=utf8 --max_allowed_packet=1G --flush-logs=FALSE --dump-date=TRUE --lock-tables=TRUE --allow-keywords=FALSE --events=FALSE --databases --routines "citihab_citi_h" > "D:\\MySQL Dumps\\Dump%date:~10,4%%date:~4,2%%date:~7,2%_%TIME:~0,2%00.sql"


    COPY "D:\MySQL Dumps\Dump%date:~10,4%%date:~4,2%%date:~7,2%_%TIME:~0,2%00.sql" B:\

     

    Wednesday, October 12, 2011 1:08 PM
  • The service is 'started'  but the "Log on As" column shows 'Local System' would this make a difference if I created the batch file with the "administrator" account?

     

    Also when I click on the 'properties' for this service I am unable to edit anything  as you recommended.

    • Edited by Ben___ Wednesday, October 12, 2011 1:17 PM
    Wednesday, October 12, 2011 1:15 PM
  • Are D:\ and B:\ both local drives? Does the account the task runs with have write permissions here?

     

     

     

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Thursday, October 13, 2011 1:21 AM
  • Hi,

     

    How is everything going? Could you please tell us the present situation? Could you try to close the UAC to test? If you need any further assistance, please do not hesistate to respond back.

     

    Thanks!


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Edited by Elytis Cheng Wednesday, October 19, 2011 2:35 AM
    Monday, October 17, 2011 1:43 AM
  • I have this same issue where I created a scheduled task that runs a batch file. The task scheduler states that it's successful, but it doesn't run the batch file. The batch runs a simple ftp script that runs fine when I double click on it, but just won't work in the scheduler.

    Any idea's

    Sniffles

    I found this links that fixed my issue.

    http://www.blogfodder.co.uk/2012/4/20/win-2008-task-scheduler-with-return-code-1-0x1

    • Proposed as answer by Sniffles530 Thursday, January 30, 2014 8:32 PM
    • Unproposed as answer by Sniffles530 Thursday, January 30, 2014 8:33 PM
    • Proposed as answer by Sniffles530 Thursday, January 30, 2014 8:33 PM
    • Unproposed as answer by Sniffles530 Thursday, January 30, 2014 8:33 PM
    • Edited by Sniffles530 Thursday, January 30, 2014 8:34 PM
    Thursday, January 30, 2014 8:25 PM