guid="62AF1627-7400-41B8-BE37-15792067BAC0"
import os
import re
import ctypes
import time
import subprocess 

start=time.time()

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)

def Uninstall(guid):
    with disable_file_system_redirection():
        
        print "Symantec endpoint uninstallation has started"
        cmd="MsiExec.exe /X{%s} /qn"%guid
        print cmd
        process = subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        stdout = process.communicate()[0]
        cmd=os.popen("wmic product get name").read()
        if  'Symantec' in cmd:
            print "Symantec need to restart your  system and run the script Again"
        else:
            print "Symantec endpoint protection uninstalled successfully"
            


Uninstall(guid)
end=time.time()
print("Execution Time: {:.2f} ".format(end-start))
