Question

I am looking for a way to basically create a clock to store the current windows time. The reason I need a separate clock is I am changing the windows system time using python. So I would like to set the windows clock back to what the time should be after a whole bunch of other java and batch files has executed.

Was it helpful?

Solution

If you are using win32api then use win32api.GetSystemTime and win32api.SetSystemTime:

system_time = win32api.GetSystemTime()
# do stuff here
import subprocess
filepath="D:/path/to/batch/myBatch.bat"
p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
stdout, stderr = p.communicate()
#p.returncode is 0 if success
# more stuff
win32api.SetSystemTime(*system_time)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top