0

I have attempted to create a scheduled task to start the w32_time task when I log on, since my windows installation - seems to want to ignore that real dst settings for my locale when I reboot - and I have to force a time update to get the clock right.

My user is an Admin user - and I can run the task manually from the an administrator command prompt.

In the scheduled task it has 'Run with highest privileges' set on - but the task fails with return code 2147943456 - which as far as I can tell means Access Denied; I am assuming this is due to a privelege issue.

This happens regardless of 'Run when user is logged on' is set or not.

If this matters; the task is scheduled to run when a user logs in.

DavidPostill
  • 156,873
  • Have you tried to run the task at fixed time? See if it fails if you set it to run every five minutes or so. – jitendragarg Jun 25 '17 at 07:17
  • Yes tried all of that it s fails with an Access Denied message. It is the same error code when I try to run that command in a normal (not admin) command prompt – Tony Suffolk 66 Jun 25 '17 at 07:22
  • why on earth did this get downvotes - did I ask in the wrong place ? – Tony Suffolk 66 Jun 25 '17 at 22:06
  • I have no idea why the downvotes. Also, I got an idea. What if you change the task to do something else with everything else being the same. That should help us narrow down if it is scheduler that requires access elevation or the program. – jitendragarg Jun 26 '17 at 04:22
  • @jitendragarg - I have confirmed that - Task scheduler will run a simple .bat file - and will even run it with admin privs - so I have decided to add the command into a bat file - although surely it should work without that level of indirection. – Tony Suffolk 66 Jun 26 '17 at 19:20
  • Are you trying to run the shortcut to the scheduled tasks, on a laptop, tablet or some other device with a battery? – Corporate Geek Sep 21 '18 at 08:25
  • @CorporateGeek - it is on a laptop - which is always plugged into the mains. I would be concerned if Windows dealt with permissions differently if the machine had a battery. As you can see from the accepted answer this was down to the permissions the Task Scheduler seems to use - it is very odd. – Tony Suffolk 66 Sep 22 '18 at 09:13
  • 1
    I was asking because I had a similar problem and I did not understand why. In my case, as documented here, I should have unchecked the setting that says "Start the task only if the computer is on AC power." – Corporate Geek Sep 24 '18 at 15:20

3 Answers3

1

An (untested) idea: Try making a shortcut icon to run the program, and have the shortcut icon run with UAC elevation; then have Task Scheduler run that shortcut.

TOOGAM
  • 15,798
  • 5
  • 43
  • 63
  • I have tried this - using the task scheduler to run a bat file with elevated privs. I will let you know. – Tony Suffolk 66 Jun 26 '17 at 19:22
  • Having tried it over a few reboots - it does seem to work - I will mark this as answered. For the record - the Task Scheduler is set to use Higher privileges - and the bat file is a ordinary script, which detects if Admin rights are enabled - and returns an exit code if the the time sync command is executed. – Tony Suffolk 66 Jun 26 '17 at 22:26
1

So I've had these issues before and had to go back to my notepad to find the references, that helped explain things for me. This isn't specifically for Windows 10, but it may help answer some of the things that happen behind the scenes and it provides some tips to "debug" what's happening.

https://blogs.technet.microsoft.com/askperf/2015/02/18/help-my-scheduled-task-does-not-run/ by Blake Morrison in Windows Server Performance Team

ConceptRat
  • 111
  • 2
0

I had the same problem trying to sync on startup. Looked everywhere. Eventually I learned enough to succeed, but not from any single source. I hope this will help those looking for answers.

  • Run Task Scheduler as admin:

    • right-click "taskschd.msc" in "C:\Windows\System32" and choose Run as Admin.
  • Create basic task: in "Task Scheduler Library -> Microsoft -> Windows -> Time Synchronization"

    • right-click to choose "Create Basic Task".
    • Follow the instructions and choose what you intend to do: Start a program "C:\Windows\System32\w32tm.exe".
    • Add arguments: "/resync" (without quotes, of course).
  • In Properties of your created basic task:

    • Choose "Change User or Group".
    • Where it says "Enter the object name to select", type in "LOCAL SERVICE".
    • It'll be changed to "nt authority/local service". Click OK.
    • It'll be shown as "LOCAL SERVICE" just like other Windows 10 tasks.
    • Check "whether user is logged on or not" and check "Run with highest privileges".
    • Check Configure for: "Windows 10".

    This is how you run scheduled task as admin!

  • Under Conditions, check "Start only if the following network connection is available: any connection".

    • Check each tab to be sure they are configured the way you want.
  • The Key point here is that you have to change the User to this Local Service thing - even if your User has admin rights. Good old Windows 10 - how to make things complex. Even when MS bolt on security after the fact they still mess it up :-( – Tony Suffolk 66 Dec 18 '20 at 22:58