0

I have written a basic program that takes the current internet time and adjusts the system time to be 2 mins ahead. The code can be seen below:

from datetime import timedelta
from datetime import datetime
import win32api
from urllib.request import urlopen
import admin



res = urlopen('http://just-the-time.appspot.com/')
result = res.read().strip()
now = result.decode('utf-8')


new_time = datetime.strptime(now, "%Y-%m-%d %H:%M:%S") + timedelta(hours=0, minutes=2, seconds=0)



year = new_time.year
month = new_time.month
day = new_time.day
hour = new_time.hour
minute = new_time.minute
second = new_time.second

win32api.SetSystemTime(year, month, 0, day, hour, minute, second,0)

print(new_time)

The program works perfectly when using the Pycharm IDE, however when I try to compile the code into an .exe using auto-py-to-exe or pyinstaller, the code runs but no changes are made to the system time. I have tried running as administrator but this doesn't seem to help. Can anyone help?

0 Answers0