Run .bat file with administrator privilege at startup
Asked Answered
I

4

6

I'm using Ubuntu and Windows on the same machine, and always have problem with incorrect time when booting into Windows, so I like to execute w32tm /resync at startup.

So I'm trying to put this command into a .bat file and place it in the startup folder, but this command requires administrator privilege, so please guide me what to do to make this work.

Thanks.

I'm using Windows 7 Ultimate edition.

Internationalize answered 12/4, 2014 at 23:35 Comment(0)
C
8

Schedule it in Task Schedule and tick the required boxes for elevation or run it as system.

Casto answered 12/4, 2014 at 23:41 Comment(0)
D
9

check the box

Just check that box as you set up the task and you are all set!

Discordance answered 12/4, 2014 at 23:45 Comment(3)
Create a task with the command w32tm /resync or which task to use?Internationalize
You will want to create a .bat with that command inside, like you were talking about. Then just have that run at start up under the triggers and actions tabs.Discordance
I had to set the event up for "Windows 8.1" on the General tab in my case for the event to run properly.Saxony
C
8

Schedule it in Task Schedule and tick the required boxes for elevation or run it as system.

Casto answered 12/4, 2014 at 23:41 Comment(0)
P
2

Place the full path to the command or bat file into the registry under HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce

It will run under the system account

Promptbook answered 20/5, 2014 at 18:34 Comment(1)
This is the only thing that worked. I tried several solutions from stackoverflow and elsewhere, including scheduled tasks (with running the .bat directly or via cmd.exe /s start), creating *.lnk that had "[x] Run as administrator" (calling it via scheduled tasks or via startup folder). Thank you very much, @sonyisda1Jackpot
L
0

The question that you are actually asking has already been answered but your problem is a bit different. Probably you don't need it any more since it is 10 years since you asked it but I will put my answer as well for those who end up here from Google.

Ubuntu and windows calculate the time differently. Ubuntu is using the UTC and adds the offset depending on your time zone while Windows reads directly your time zone. This is causing the clock to go back and fourth if you are dual booting like in your case.

Running: timedatectl set-local-rtc 1 --adjust-system-clock from inside Ubuntu will fix your problem permanently by telling to Ubuntu to use your time zone instead of the UTC time zone..

Libre answered 4/9 at 11:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.