import os;
import re;
import ctypes
cwd = os.getcwd()
def Uninstall(program):
	k=[];
	command ='C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe "get-wmiobject Win32_Product | Format-Table Name,IdentifyingNumber" | findstr /i /c:"'+program+'"';
	guid=os.popen(command).read();
	print(guid)
	k.append(re.findall("{.*",guid));
	j=[];
	for i in k[0]: j.append(i);
	
	for i in j: os.system('msiexec.exe /x '+i+' /quiet REBOOT=ReallySuppress REMOVE=ALL');
		
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)

with disable_file_system_redirection():
    if os.path.isfile("C:\Program Files (x86)\VIPRE Business Agent\AgentUninstallPassword.exe"):
        CMD=os.popen('wmic product where name="VIPRE Business Agent" call uninstall').read()
        print 'VIPRE Business Agent uninstalled successfully'
	
    if os.path.isfile("C:\Program Files\VIPRE Business Agent\AgentUninstallPassword.exe"):
        CMD1=os.popen('wmic product where name="VIPRE Business Agent" call uninstall').read()
        print 'VIPRE Business Agent uninstalled successfully'
	
    if os.path.isfile("C:\Program Files (x86)\Malwarebytes' Anti-Malware\unins000.exe"):
        os.chdir("C:\Program Files (x86)\Malwarebytes' Anti-Malware")
        out=os.popen("unins000.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART").read();
        print 'Malwarebytes Managed Client uninstalled successfully'
        os.chdir(cwd);		

    if os.path.isfile("C:\Program Files\Malwarebytes' Anti-Malware\unins000.exe"):
        os.chdir("C:\Program Files\Malwarebytes' Anti-Malware")
        out=os.popen("unins000.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART").read();
        print 'Malwarebytes Managed Client uninstalled successfully'
        os.chdir(cwd);		
    
    if os.path.isfile("C:\Program Files (x86)\Malwarebytes Anti-Exploit\unins000.exe"):
        os.chdir("C:\Program Files (x86)\Malwarebytes Anti-Exploit")
        out=os.popen("unins000.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART").read();
        print ' Malwarebytes Anti-Exploit uninstalled successfully'
        os.chdir(cwd);	

    if os.path.isfile("C:\Program Files\Malwarebytes Anti-Exploit\unins000.exe"):
        os.chdir("C:\Program Files\Malwarebytes Anti-Exploit")
        out=os.popen("unins000.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART").read();
        print 'Malwarebytes Anti-Exploit uninstalled successfully'
        os.chdir(cwd);

    if os.path.isfile("C:\Program Files\Malwarebytes\Anti-Malware\unins000.exe"):
        os.chdir("C:\Program Files\Malwarebytes\Anti-Malware")
        out=os.popen("unins000.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART").read();
        print 'Malwarebytes uninstalled successfully'
        
Uninstall("Malwarebytes' Managed Client");
