threshold_days = 0 # give the days here for eg: threshold_days = 2. the datatype should be integer.
title = 'Your computer needs to be restarted'
message = """Our Systems have detected that your PC was not restarted since atleast %s days, As this may result in
performance problems, we strongly recommend that you should restart it as soon as possible.

you can click on 'RESTART NOW' button to restart you pc. please save your documents before proceeding
with the restart.

- IT Department
"""

fromURL='https://script-downloads.comodo.com/graphic-image.gif'## Here mention the download url

import os
import ctypes
from subprocess import PIPE, Popen
import ctypes
import urllib2
import ssl
import re
from Tkinter import *
import Tkinter as tk   
from Tkinter import *
import tkMessageBox  as mb

root=tk.Tk()


class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:
            self._revert(self.old_value)

Down_path=os.environ['TEMP']
fileName = fromURL.split('/')[-1]
DownTo = os.path.join(Down_path, fileName)

def downloadFile(DownTo, fromURL):
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
    context = ssl._create_unverified_context()
    request = urllib2.Request(fromURL, headers=headers)
    req = urllib2.urlopen(request,context=context)
    try:
        with open(DownTo, 'wb') as f:
            while True:
                chunk = req.read(100*1000*1000)
                if chunk:
                    f.write(chunk)
                else:
                    break
    except:
        return 'Please Check URL or Download Path!'

def GUI(title,message,path):
    root.geometry("622x650")
    root.title(' '*59+title)
    canvas = Canvas(root,width=622,height=431)
    canvas.pack()
    image = PhotoImage(file=path)
    canvas.create_image(0,0,anchor=NW,image=image)
    l1=Label(text=message,font=("Arial", 10))
    l1.pack()

    b1=Button(root,text="RESTART NOW",command=callyes,height = 1, width = 11, highlightbackground='#3E4149')
    b1.pack(pady=15)
    root.lift()
    root.attributes('-topmost',True)
    root.after_idle(root.attributes,'-topmost',False)
    root.protocol("WM_DELETE_WINDOW", on_closing)
    root.mainloop()

def callyes():
    root.destroy()
    print("user clicked the 'RESTART NOW' button")
    with disable_file_system_redirection():
        OBJ = Popen('shutdown -r', shell = True, stdout = PIPE, stderr = PIPE)
        out, err = OBJ.communicate()
        code = OBJ.returncode
        if code==0:
            print("restarting the system")
        os.remove(DownTo)

def on_closing():
    root.destroy()
    print("user closed the Reminder Window without clicking the RESTART NOW button")
    os.remove(DownTo)

with disable_file_system_redirection():
    OBJ = Popen(['powershell',r'(get-date) - (gcim Win32_OperatingSystem).LastBootUpTime'], shell = True, stdout = PIPE, stderr = PIPE)
    out, err = OBJ.communicate()
    if err:
        print(err)
    else:
        data = re.findall('Days.*:(.*)',out)
        days = int(data[0].strip())
        if threshold_days <= days:
            downloadFile(DownTo, fromURL)
            GUI(title,message%(days),DownTo)
        else:
            print('the uptime of the system is lesser than the threshold_days')