Artisan
Artisan

Reputation: 4112

Run .bat file with administrator privilege at startup

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.

Upvotes: 6

Views: 16865

Answers (4)

xrononautis
xrononautis

Reputation: 5

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

Upvotes: 0

Stormy
Stormy

Reputation: 21

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

Upvotes: 2

Isaiah Taylor
Isaiah Taylor

Reputation: 627

check the box

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

Upvotes: 9

tony bd
tony bd

Reputation: 460

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

Upvotes: 8

Related Questions