windows - Only administrator account can run scheduled tasks

18
2014-03
  • Seany84

    I am running Windows 2008 Server and I have set up a scheduled task that executes a SQL script from the command prompt. The script and command work completely fine.

    I set this scheduled task to run once a day, under the Administrator user account and it has been working fine for over a week. I now want to disable the Administrator account and run the scheduled task as another user (with exactly the same privileges i.e. Users, Administrators).

    When I change the user for the scheduled task and try to run it. The Task Scheduler tells me that the task has run (Last run result: 0x0) but the script has not been executed.

    Scheduled Task information

    • Run whether user is logged in or not (true)
    • Run with highest privileges (true)

    tl;dr Changing an already working scheduled task running under Administrator to another user account stops the scheduled task working (user has same role/privileges).

  • Answers
  • Seany84

    The problem was that even though the user had Administrator privileges on the Windows Server it did not have sysadmin or dbo privileges on the SQL server DB/instance. By giving my user these privileges on SQL Server the script executed.


  • Related Question

    windows - Task Scheduler: Run whether user is logged in or not: not working
  • ajoe

    I have a Task scheduled to run in Windows server 2008 (start up notepad). It seems to work fine when "Run whether user is logged in or not" is not selected. however when I select it the the task no longer runs, Status says: Queued.

    I'm not using any mapped drives for this.


  • Related Answers
  • Randolf Richardson

    Notepad is an application that requires user interaction. To run a task when a user isn't logged in, you need to run something that can run unattended without user interaction.

    Create a batch file with the following lines in it (make sure the path c:/temp/ exists; it should, but double-check because Windows versions since XP usually don't create it automatically):

    • @echo off
    • date /t >> c:\temp\task-test.log
    • time /t >> c:\temp\task-test.log
    • echo ------------>> c:\temp\task-test.log
    • cls
    • exit

    Then, set up a task that runs that file. You can check the contents of the file "c:\temp\task-test.log" using Windows Notepad to see what times and dates your task successfully ran that batch file.

    If this works, then it probably means that the interactive requirements of Notepad are the issue.