kbvalue=itsm.getParameter("kbvalue")#"KB5004237"
import Tkinter as tk   
from Tkinter import *
import tkMessageBox  as mb
import os
import time
from subprocess import Popen,PIPE
start=time.time()

def cmd_exec(cmd):
    obj=Popen(cmd,stdout=PIPE,stderr=PIPE)
    res,err=obj.communicate()
    if err:
        return err
    else:
        return res
    
root=tk.Tk()
root.geometry("400x100")
root.title("Windows Update Prompt !")
l1=Label(text="Do you want update windows now ?",font=("Arial", 10))
l1.pack()
def callyes():
    root.destroy()
    print cmd_exec('powershell "Set-ExecutionPolicy RemoteSigned"')
    print cmd_exec('powershell "Install-Module PSWindowsUpdate -Force"')
    print cmd_exec('''powershell "Get-WindowsUpdate -Install -KBArticleID '%s' -Confirm:$false -IgnoreReboot" '''%kbvalue)
    #print cmd_exec('Get-hotfix')

def callno():
    res = mb.askquestion('Exit Application', 
                         'Do you really want to exit')
      
    if res == 'yes' :
        print("User Has Choosed 'NO' for update")
        root.destroy()
          
    else :
        mb.showinfo('Return', 'Returning to main application')
    
b1=Button(root,text="Okay",command=callyes,height = 1, width = 10)
b2=Button(root,text="Exit",command=callno,height = 1, width = 10)

b1.pack(pady=2)
b2.pack(pady=2)
root.lift()
root.attributes('-topmost',True)
root.after_idle(root.attributes,'-topmost',False)
root.mainloop()

end=time.time()
print("Execution Successful")
print("Exceution Time : %s"%(end-start))