Friday, October 9, 2015

windows - Only administrator account can run scheduled tasks


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).


Answer



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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...