I want to run a batch file(say wanted to run calculator) on a specific date and time using python (but don't use the default scheduler). My program:
a = "C:\Windows\system32\calc.exe"
mybat = open(r"D:\Cyber_security\Python\cal.bat", "w+")
mybat.write(a)
mybat.close()
import datetime
start = datetime.datetime.now()
end = datetime.datetime(2022, 7, 12, 17, 29, 10)
while(True):
if(end - start == 0):
import subprocess
subprocess.call([r"D:\Cyber_security\Python\cal.bat"])
when I run it it doesn't show error but the batch file is not running at specific time. where is the wrong?
startis never updated. It'll always contain the time when you launched the script, soend - startwill be a constant.