Hello
Employees of our institution do not turn off their computers. Therefore, slowdowns occur in computers. The updates we made through Windows update are not installed. This situation causes problems during the work.
To solve this, I want to reboot the computers that are on everyday at 5 am.
As far as I have viewed on your site https://scripts.itarian.com/frontend…task-scheduler
you have this script.
daily="DAILY" #Eg:DAILY,MON,TUE,WED,THU,FRI,SAT,SUN
time="20:00" #TIME-should be in 24 hour format
import os
import subprocess
import socket
from ctypes import *
class disable_file_system_redirection:
_disable = windll.kernel32.Wow64DisableWow64FsRedirection
_revert = windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value =c_long()
self.success = self._disable(byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
command='shutdown -r -f'
def command1(daily,time,command):
path=os.environ['PROGRAMDATA']
command='"'+command+'"'
if os.path.exists(path):
os.chdir(path)
with open("reboot_command.bat","w+") as f:
f.write('start cmd.exe /k '+command)
f.close()
file_path = os.environ['PROGRAMDATA'] + r'\reboot_command.bat'
print file_path
cmd='schtasks /ru "SYSTEM" /create /tn:reboot /tr:'+file_path+" /sc:"+daily+" /st:"+time+" /f"
with disable_file_system_redirection():
ping = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr = subprocess.PIPE,shell=True)
out = ping.communicate()
if len(out[0])>0:
print "Task Scheduler Scheduled to restart system at "+time
else:
print "Error in task scheduler.Please check your parameters"
command1(daily,time,command)
Do I need to run this script everyday or can I just run it once?
Water is what I want to learn. Does our script run smoothly on windows xp / 7/8/10. Do I need to send this script to devices once? What should I do if I want to cancel this script later.
In the AntiVrüs program, we could scan with time settings.
As follows. Is there a feature in the computer that I can restart in this way?
Could you help