#########################Configuration#Section##########################################################################
# This Remediation Procedure will allow you to keep track up to 10 applications
# This procedure will installl the applicatiion if is not present based on the settings selected
# Please use the same number that use have used in the Monitor
##########################################################################
# Application 1
######################################
VerifyIfApplication1IsPresent = "yes"
Application1Name = "Notepad++"
# If the installer is MSI based, please modify this section
Application1InstallIsMSI = "no"
Application1MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application1InstallIsEXE = "yes"
Application1EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application1PackageIsURL = "no"
Application1PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application1PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application1PackageIsURLVerifyDownload = "no"
Application1PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application1PackageIsGoogle = "no"
Application1PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application1FileNameGoogleX32=r'name'
Application1ExtensionGoogleX32=r'.msi'
Application1PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application1FileNameGoogleX64=r'name'
Application1ExtensionGoogleX64=r'.exe'
Application1PackageIsGoogleVerifyDownload = "no"
Application1PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application1PackageIsSharedFolder = "no"
Application1PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application1FileNameSharedFolderX32 = r'name.msi'
Application1FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application1Reboot = "no"
Application1RebootTime = "300"
Application1RebootComment = "Application1 requesting endpoint reboot"
######################################
# Application 2
######################################
VerifyIfApplication2IsPresent = "no"
Application2Name = ""
# If the installer is MSI based, please modify this section
Application2InstallIsMSI = "no"
Application2MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application2InstallIsEXE = "no"
Application2EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application2PackageIsURL = "no"
Application2PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application2PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application2PackageIsURLVerifyDownload = "no"
Application2PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application2PackageIsGoogle = "no"
Application2PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application2FileNameGoogleX32=r'name'
Application2ExtensionGoogleX32=r'.msi'
Application2PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application2FileNameGoogleX64=r'name'
Application2ExtensionGoogleX64=r'.exe'
Application2PackageIsGoogleVerifyDownload = "no"
Application2PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application2PackageIsSharedFolder = "no"
Application2PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application2FileNameSharedFolderX32 = r'name.msi'
Application2FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application2Reboot = "no"
Application2RebootTime = "300"
Application2RebootComment = "Application2 requesting endpoint reboot"
######################################
# Application 3
######################################
VerifyIfApplication3IsPresent = "no"
Application3Name = ""
# If the installer is MSI based, please modify this section
Application3InstallIsMSI = "no"
Application3MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application3InstallIsEXE = "no"
Application3EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application3PackageIsURL = "no"
Application3PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application3PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application3PackageIsURLVerifyDownload = "no"
Application3PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application3PackageIsGoogle = "no"
Application3PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application3FileNameGoogleX32=r'name'
Application3ExtensionGoogleX32=r'.msi'
Application3PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application3FileNameGoogleX64=r'name'
Application3ExtensionGoogleX64=r'.exe'
Application3PackageIsGoogleVerifyDownload = "no"
Application3PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application3PackageIsSharedFolder = "no"
Application3PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application3FileNameSharedFolderX32 = r'name.msi'
Application3FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application3Reboot = "no"
Application3RebootTime = "300"
Application3RebootComment = "Application3 requesting endpoint reboot"
######################################
# Application 4
######################################
VerifyIfApplication4IsPresent = "no"
Application4Name = ""
# If the installer is MSI based, please modify this section
Application4InstallIsMSI = "no"
Application4MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application4InstallIsEXE = "no"
Application4EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application4PackageIsURL = "no"
Application4PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application4PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application4PackageIsURLVerifyDownload = "no"
Application4PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application4PackageIsGoogle = "no"
Application4PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application4FileNameGoogleX32=r'name'
Application4ExtensionGoogleX32=r'.msi'
Application4PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application4FileNameGoogleX64=r'name'
Application4ExtensionGoogleX64=r'.exe'
Application4PackageIsGoogleVerifyDownload = "no"
Application4PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application4PackageIsSharedFolder = "no"
Application4PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application4FileNameSharedFolderX32 = r'name.msi'
Application4FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application4Reboot = "no"
Application4RebootTime = "300"
Application4RebootComment = "Application4 requesting endpoint reboot"
######################################
# Application 5
######################################
VerifyIfApplication5IsPresent = "no"
Application5Name = ""
# If the installer is MSI based, please modify this section
Application5InstallIsMSI = "no"
Application5MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application5InstallIsEXE = "no"
Application5EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application5PackageIsURL = "no"
Application5PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application5PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application5PackageIsURLVerifyDownload = "no"
Application5PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application5PackageIsGoogle = "no"
Application5PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application5FileNameGoogleX32=r'name'
Application5ExtensionGoogleX32=r'.msi'
Application5PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application5FileNameGoogleX64=r'name'
Application5ExtensionGoogleX64=r'.exe'
Application5PackageIsGoogleVerifyDownload = "no"
Application5PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application5PackageIsSharedFolder = "no"
Application5PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application5FileNameSharedFolderX32 = r'name.msi'
Application5FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application5Reboot = "no"
Application5RebootTime = "300"
Application5RebootComment = "Application5 requesting endpoint reboot"
######################################
# Application 6
######################################
VerifyIfApplication6IsPresent = "no"
Application6Name = ""
# If the installer is MSI based, please modify this section
Application6InstallIsMSI = "no"
Application6MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application6InstallIsEXE = "no"
Application6EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application6PackageIsURL = "no"
Application6PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application6PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application6PackageIsURLVerifyDownload = "no"
Application6PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application6PackageIsGoogle = "no"
Application6PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application6FileNameGoogleX32=r'name'
Application6ExtensionGoogleX32=r'.msi'
Application6PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application6FileNameGoogleX64=r'name'
Application6ExtensionGoogleX64=r'.exe'
Application6PackageIsGoogleVerifyDownload = "no"
Application6PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application6PackageIsSharedFolder = "no"
Application6PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application6FileNameSharedFolderX32 = r'name.msi'
Application6FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application6Reboot = "no"
Application6RebootTime = "300"
Application6RebootComment = "Application6 requesting endpoint reboot"
######################################
# Application 7
######################################
VerifyIfApplication7IsPresent = "no"
Application7Name = ""
# If the installer is MSI based, please modify this section
Application7InstallIsMSI = "no"
Application7MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application7InstallIsEXE = "no"
Application7EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application7PackageIsURL = "no"
Application7PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application7PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application7PackageIsURLVerifyDownload = "no"
Application7PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application7PackageIsGoogle = "no"
Application7PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application7FileNameGoogleX32=r'name'
Application7ExtensionGoogleX32=r'.msi'
Application7PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application7FileNameGoogleX64=r'name'
Application7ExtensionGoogleX64=r'.exe'
Application7PackageIsGoogleVerifyDownload = "no"
Application7PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application7PackageIsSharedFolder = "no"
Application7PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application7FileNameSharedFolderX32 = r'name.msi'
Application7FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application7Reboot = "no"
Application7RebootTime = "300"
Application7RebootComment = "Application7 requesting endpoint reboot"
######################################
# Application 8
######################################
VerifyIfApplication8IsPresent = "no"
Application8Name = ""
# If the installer is MSI based, please modify this section
Application8InstallIsMSI = "no"
Application8MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application8InstallIsEXE = "no"
Application8EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application8PackageIsURL = "no"
Application8PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application8PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application8PackageIsURLVerifyDownload = "no"
Application8PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application8PackageIsGoogle = "no"
Application8PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application8FileNameGoogleX32=r'name'
Application8ExtensionGoogleX32=r'.msi'
Application8PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application8FileNameGoogleX64=r'name'
Application8ExtensionGoogleX64=r'.exe'
Application8PackageIsGoogleVerifyDownload = "no"
Application8PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application8PackageIsSharedFolder = "no"
Application8PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application8FileNameSharedFolderX32 = r'name.msi'
Application8FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application8Reboot = "no"
Application8RebootTime = "300"
Application8RebootComment = "Application8 requesting endpoint reboot"
######################################
# Application 9
######################################
VerifyIfApplication9IsPresent = "no"
Application9Name = ""
# If the installer is MSI based, please modify this section
Application9InstallIsMSI = "no"
Application9MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application9InstallIsEXE = "no"
Application9EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application9PackageIsURL = "no"
Application9PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application9PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application9PackageIsURLVerifyDownload = "no"
Application9PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application9PackageIsGoogle = "no"
Application9PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application9FileNameGoogleX32=r'name'
Application9ExtensionGoogleX32=r'.msi'
Application9PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application9FileNameGoogleX64=r'name'
Application9ExtensionGoogleX64=r'.exe'
Application9PackageIsGoogleVerifyDownload = "no"
Application9PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application9PackageIsSharedFolder = "no"
Application9PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application9FileNameSharedFolderX32 = r'name.msi'
Application9FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application9Reboot = "no"
Application9RebootTime = "300"
Application9RebootComment = "Application8 requesting endpoint reboot"
######################################
# Application 10
######################################
VerifyIfApplication10IsPresent = "no"
Application10Name = ""
# If the installer is MSI based, please modify this section
Application10InstallIsMSI = "no"
Application10MSISilentSwitches = r'/qn'
# If the installer is EXE based, please modify this section
Application10InstallIsEXE = "no"
Application10EXESilentSwitches = r'/quiet'
# In this section you will specify from where the installation package will be downloaded
# If the package is present on a specific URL please modify this section
Application10PackageIsURL = "no"
Application10PackageURLX32 = r'https://youurl.com/application_x32.msi'
Application10PackageURLX64 = r'https://youurl.com/application_x64.exe'
Application10PackageIsURLVerifyDownload = "no"
Application10PackageIsURLBytes = ""
# If the package is present on Google Drive please modify this section
# Note the structure of the Google Drive link example 
Application10PackageIsGoogle = "no"
Application10PackageGoogleX32 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application10FileNameGoogleX32=r'name'
Application10ExtensionGoogleX32=r'.msi'
Application10PackageGoogleX64 = r'https://drive.google.com/uc?authuser=0&id=1EFg-2CyNOY5IpRrTIt-6rb8GybFcN4-k&export=download'
Application10FileNameGoogleX64=r'name'
Application10ExtensionGoogleX64=r'.exe'
Application10PackageIsGoogleVerifyDownload = "no"
Application10PackageIsGoogleBytes = ""
# If the package is present on a Shared Folder please modify this section
Application10PackageIsSharedFolder = "no"
Application10PackageIsSharedFolderFolderPath = r'\\adserver\sharefolder'
Application10FileNameSharedFolderX32 = r'name.msi'
Application10FileNameSharedFolderX64 = r'name.exe'
# If your application downloaded from any location will require that the endpoint needs to reboot after is installed, please modify this section
Application10Reboot = "no"
Application10RebootTime = "300"
Application10RebootComment = "Application8 requesting endpoint reboot"
######################################
# Proxy section
# In this section you will be able to specify that any download done by this procedure will use an explicit proxy
useproxy = "no"
proxyhost = "10.10.10.1"
proxyport = "3128"
useauth = "no"
proxyuser = ""
proxypassw = ""
ifproxydownbypass = "yes"
########################################################################################################################
import os
from subprocess import PIPE, Popen
import shutil
import ctypes
import re
import datetime
import platform
import subprocess
import socket

try:
    import winreg as _winreg
except ImportError:
    try:
        import _winreg
    except ImportError:
        pass
import ssl
import time

try:
    import urllib.request as urllib2
except ImportError:
    try:
        import urllib2
    except ImportError:
        pass

min = '10'
allowtorun=0
datenow = datetime.datetime.now()
datestamp = datenow + datetime.timedelta(minutes = int(min) -1)
retry = 5
delay = 10
timeout = 3

def isOpen(ip, port):
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.settimeout(timeout)
		try:
			s.connect((ip, int(port)))
			s.shutdown(socket.SHUT_RDWR)
			return True
		except:
			return False
		finally:
			s.close()

def checkHost(ip, port):
    ipup = False
    for i in range(retry):
        if isOpen(ip, port):
            ipup = True
            break
        else:
            time.sleep(delay)
    return ipup

# Create 'TimeStampStatus' file and write current time
def WriteTimeStampToTheTimeStampFile(datetowrite):
	Path_for_time_stamp_file = r""
	Os_Path = r"{0}\Program Files (x86)".format(os.environ['systemdrive'])
	if os.path.exists(Os_Path):
		Path_for_time_stamp_file = r"{0}\Program Files (x86)\ITarian\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
	else:
		Path_for_time_stamp_file = r"{0}\Program Files\ITarian\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
	open(Path_for_time_stamp_file, "w+").write(str(datetowrite.strftime("%y-%m-%d %H:%M:%S")))

# read 'TimeStampStatus' file
def readTimeStampStatus():
	Path_for_time_stamp_file = r""
	Os_Path = r"{0}\Program Files (x86)".format(os.environ['systemdrive'])
	if os.path.exists(Os_Path):
		Path_for_time_stamp_file = r"{0}\Program Files (x86)\ITarian\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
	else:
		Path_for_time_stamp_file = r"{0}\Program Files\ITarian\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
	vartime = open(Path_for_time_stamp_file, "r")
	time = vartime.read()
	return time

def verifyfileexist():
	Path_for_time_stamp_file = ""
	Os_Path = r"{0}\Program Files (x86)".format(os.environ['systemdrive'])
	if os.path.exists(Os_Path):
		Path_for_time_stamp_file = r"{0}\Program Files (x86)\ITarian\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
	else:
		Path_for_time_stamp_file = r"{0}\Program Files\ITarian\Endpoint Manager\rmmlogs\TimeStampStatus.txt".format(os.environ['systemdrive'])
	return Path_for_time_stamp_file

def GetWindowsEdition(Key_name):
	val = ""
	try:
		reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
		ok = _winreg.OpenKey(reg, Key_name, 0, _winreg.KEY_WOW64_32KEY | _winreg.KEY_READ)
		val = _winreg.QueryValueEx(ok, "ProductName")[0]
		_winreg.CloseKey(ok)
		return val
	except Exception as exception:
		val = "Windows Registry Exception: " + str(exception)
		return val

WindowsVersion = GetWindowsEdition('SOFTWARE\Microsoft\Windows NT\CurrentVersion')

class disable_file_system_redirection:
		try:
			_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)
		except:
			pass

def ecmd(command, output=False):
	if not ("XP" in WindowsVersion or "2008" in WindowsVersion):
		with disable_file_system_redirection():
			objt = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
			out, err = objt.communicate()
			ret = objt.returncode
	else:
		objt = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
		out, err = objt.communicate()
		ret = objt.returncode
	if not out:
		return ret
	else:
		return '%s\n%s' % (out, err)

## detect all installed software through registry key            
def DNDS(rtkey, pK, kA):
	ln = []
	lv = []
	try:
		oK = _winreg.OpenKey(rtkey, pK, 0, kA)
		i = 0
		while True:
			try:
				bkey = _winreg.EnumKey(oK, i)
				vkey = os.path.join(pK, bkey)
				oK1 = _winreg.OpenKey(rtkey, vkey, 0, kA)
				try:
					tls = []
					DN, bla = _winreg.QueryValueEx(oK1, 'DisplayName')
					DV, bla = _winreg.QueryValueEx(oK1, 'UninstallString')
					_winreg.CloseKey(oK1)
					ln.append(DN)
					lv.append(DV)
				except:
					pass
				i += 1
			except:
				break
		_winreg.CloseKey(oK)
		return zip(ln, lv)
	except:
		return zip(ln, lv)

def GetSoftwareUsingRegistry():
	## detect whether the computer is 32 bit or 64 bit
	rK = _winreg.HKEY_LOCAL_MACHINE
	sK = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
	openedKey = _winreg.OpenKey(rK, sK, 0, _winreg.KEY_READ)
	arch, bla = _winreg.QueryValueEx(openedKey, 'PROCESSOR_ARCHITECTURE')
	arch = str(arch)
	_winreg.CloseKey(openedKey)
	## sorting all collected data from all the way, filtered duplicates and listed the final result!
	if arch == 'AMD64':
		fList = DNDS(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_32KEY | _winreg.KEY_READ)
		fList.extend(DNDS(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_64KEY | _winreg.KEY_READ))
		fList.extend(DNDS(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_32KEY | _winreg.KEY_READ))
		fList.extend(DNDS(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_WOW64_64KEY | _winreg.KEY_READ))
	else:
		fList = DNDS(_winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_READ)
		fList.extend(DNDS(_winreg.HKEY_CURRENT_USER, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', _winreg.KEY_READ))
	fList = set(fList)
	j = 1
	FinalResultAVG = ""
	for i in sorted(fList):
		a, b = i
		try:
			resultavg = '{:<100}'.format(a.encode('utf-8'))
			FinalResultAVG = FinalResultAVG + '\n' + resultavg
		except:
			FinalResultAVG = FinalResultAVG + '\n' + a
		j += 1
	return FinalResultAVG

GetSoftwareUsingRegistryResult = ""
GetSoftwareUsingRegistryResult = GetSoftwareUsingRegistry()

def DownloadURL(Download_URL, Download_Path):
	fileName = Download_URL.split('/')[-1]
	print('Downloading ' + fileName)
	DownTo = os.path.join(Download_Path, fileName)
	proxy = ""
	httpproxy = ""
	httpsproxy = ""
	if useproxy is "yes":
		if useauth is "yes":
			httpproxy='http://'+proxyuser+':'+proxypassw+'@'+proxyhost+':'+proxyport
			httpsproxy='https://'+proxyuser+':'+proxypassw+'@'+proxyhost+':'+proxyport
		else:
			httpproxy='http://'+proxyhost+':'+proxyport
			httpsproxy='https://'+proxyhost+':'+proxyport

	proxifinal = {'http': httpproxy, 'https': httpsproxy}
	print(proxifinal)
	if useproxy is "yes":
		import urllib
		if ifproxydownbypass is "yes":
			if checkHost(proxyhost, proxyport):
				import urllib2
				proxy_support = urllib2.ProxyHandler(proxifinal)
				opener = urllib2.build_opener(proxy_support)
				urllib2.install_opener(opener)
				print("Option 1 useproxy=yes ifproxydownbypass=yes host is reachable")
				f = urllib2.urlopen(Download_URL)
			else:
				try:
					import urllib.request as urllib2
				except ImportError:
					try:
						import urllib2
					except ImportError:
						pass
				print("Option 2 useproxy=yes ifproxydownbypass=yes host is NOT reachable")
				try:
					context = ssl._create_unverified_context()
					f = urllib2.urlopen(Download_URL, context=context)
				except:
					f = urllib2.urlopen(Download_URL)
		else:
			import urllib2
			proxy_support = urllib2.ProxyHandler(proxifinal)
			opener = urllib2.build_opener(proxy_support)
			urllib2.install_opener(opener)
			print("Option 3 useproxy=yes ifproxydownbypass=no")
			f = urllib2.urlopen(Download_URL)
	else:
		try:
			import urllib.request as urllib2
		except ImportError:
			try:
				import urllib2
			except ImportError:
				pass
		print("Option 4 useproxy=no")
		try:
			context = ssl._create_unverified_context()
			f = urllib2.urlopen(Download_URL, context=context)
		except:
			f = urllib2.urlopen(Download_URL)
	data = f.read()
	with open(DownTo, "wb") as code:
		code.write(data)
	time.sleep(10)
	print( fileName + ' has been successfully downloaded here ' + DownTo)
	return DownTo

def InstallApplicationURL(Download_Application_URL, ApplicationPackageIsURLVerifyDownload, ApplicationPackageIsURLBytes, MSI, SwitchesMSI, EXE, SwitchesEXE, AppReboot, AppRebootTime, AppRebootComment):
    Download_URL = Download_Application_URL
    fileNameURLverify = Download_Application_URL.split('/')[-1]
    Download_Path = ""
    if ("7" in WindowsVersion or "2008 R2" in WindowsVersion or "Embedded" in WindowsVersion):
        Download_Path = os.environ['PROGRAMDATA']
    elif ("XP" in WindowsVersion or "2008" in WindowsVersion):
        Download_Path = os.environ['TEMP']
    else:
        Download_Path = os.environ['PROGRAMDATA']
    Download_Path = os.path.join( Download_Path, r'Comodo')
    if not os.path.exists(Download_Path):
        os.makedirs(Download_Path)
        print("Download path was created")
    if os.path.isdir(Download_Path):
        print('"' + Download_Path + '"' + " folder exists")
    else:
        print('"' + Download_Path + '"' + " folder do NOT exists")
    VerifyIfTheFileIsAlreadyPresentURL = os.path.join(Download_Path, fileNameURLverify)
    try:
        os.remove(VerifyIfTheFileIsAlreadyPresentURL)
    except OSError:
        pass
    pathURL = DownloadURL(Download_Application_URL, Download_Path)
    if ApplicationPackageIsURLVerifyDownload is "yes":
        pathURLfilesize = os.path.getsize(pathURL)
        if int(pathURLfilesize) == int(ApplicationPackageIsURLBytes):
            commandURL = ""
            if MSI is "yes":
                commandURL = 'msiexec /i "' + pathURL + '" ' + SwitchesMSI
                print('MSI command = ' + commandURL)
            if EXE is "yes":
                commandURL = '"' + pathURL + '" ' + SwitchesEXE
                print('EXE command = ' + commandURL)
            URLCommandResult = ecmd(commandURL, True)
            print(URLCommandResult)
            time.sleep(30)
            try:
                os.remove(VerifyIfTheFileIsAlreadyPresentURL)
            except OSError:
                pass
            if AppReboot is "yes":
                print(ecmd(r'shutdown.exe -r -t ' + AppRebootTime + ' /f /c "' + AppRebootComment + '"', True))
                print('System will restart in ' + AppRebootTime + ' seconds')
        else:
            print( fileNameURLverify + " was not copied successfully")
            print("We have " + pathURLfilesize + " bytes downloaded on the endpoint" )
            print("We need " + ApplicationPackageIsURLBytes + " bytes")
    else:
        commandURL = ""
        if MSI is "yes":
            commandURL = 'msiexec /i "' + pathURL + '" ' + SwitchesMSI
            print('MSI command = ' + commandURL)
        if EXE is "yes":
            commandURL = '"' + pathURL + '" ' + SwitchesEXE
            print('EXE command = ' + commandURL)
        URLCommandResult = ecmd(commandURL, True)
        print(URLCommandResult)
        time.sleep(30)
        try:
            os.remove(VerifyIfTheFileIsAlreadyPresentURL)
        except OSError:
            pass
        if AppReboot is "yes":
            print(ecmd(r'shutdown.exe -r -t ' + AppRebootTime + ' /f /c "' + AppRebootComment + '"', True))
            print('System will restart in ' + AppRebootTime + ' seconds')

def DownloadGoogle(Path, URL, FileName,Extension):
	Download_URL = URL
	fileName = FileName + Extension
	DownTo = os.path.join(Path, fileName)
	proxy = ""
	httpproxy = ""
	httpsproxy = ""
	if useproxy is "yes":
		if useauth is "yes":
			httpproxy='http://'+proxyuser+':'+proxypassw+'@'+proxyhost+':'+proxyport
			httpsproxy='https://'+proxyuser+':'+proxypassw+'@'+proxyhost+':'+proxyport
		else:
			httpproxy='http://'+proxyhost+':'+proxyport
			httpsproxy='https://'+proxyhost+':'+proxyport

	proxifinal = {'http': httpproxy, 'https': httpsproxy}
	print(proxifinal)
	if useproxy is "yes":
		import urllib
		if ifproxydownbypass is "yes":
			if checkHost(proxyhost, proxyport):
				import urllib2
				proxy_support = urllib2.ProxyHandler(proxifinal)
				opener = urllib2.build_opener(proxy_support)
				urllib2.install_opener(opener)
				print("Option 1 useproxy=yes ifproxydownbypass=yes host is reachable")
				f = urllib2.urlopen(Download_URL)
			else:
				try:
					import urllib.request as urllib2
				except ImportError:
					try:
						import urllib2
					except ImportError:
						pass
				print("Option 2 useproxy=yes ifproxydownbypass=yes host is NOT reachable")
				try:
					context = ssl._create_unverified_context()
					f = urllib2.urlopen(Download_URL, context=context)
				except:
					f = urllib2.urlopen(Download_URL)
		else:
			import urllib2
			proxy_support = urllib2.ProxyHandler(proxifinal)
			opener = urllib2.build_opener(proxy_support)
			urllib2.install_opener(opener)
			print("Option 3 useproxy=yes ifproxydownbypass=no")
			f = urllib2.urlopen(Download_URL)
	else:
		try:
			import urllib.request as urllib2
		except ImportError:
			try:
				import urllib2
			except ImportError:
				pass
		print("Option 4 useproxy=no")
		try:
			context = ssl._create_unverified_context()
			f = urllib2.urlopen(Download_URL, context=context)
		except:
			f = urllib2.urlopen(Download_URL)
	data = f.read()
	with open(DownTo, "wb") as code:
		code.write(data)
	time.sleep(10)
	return DownTo

def InstallApplicationGoogle(Download_Application_Google, ApplicationFileNameGoogle, ApplicationExtensionGoogle, ApplicationPackageIsGoogleVerifyDownload, ApplicationPackageIsGoogleBytes, MSI, SwitchesMSI, EXE, SwitchesEXE, AppReboot, AppRebootTime, AppRebootComment):
    fileNameURLverify = ApplicationFileNameGoogle + ApplicationExtensionGoogle
    Download_Path = ""
    if ("7" in WindowsVersion or "2008 R2" in WindowsVersion or "Embedded" in WindowsVersion):
        Download_Path = os.environ['PROGRAMDATA']
    elif ("XP" in WindowsVersion or "2008" in WindowsVersion):
        Download_Path = os.environ['TEMP']
    else:
        Download_Path = os.environ['PROGRAMDATA']
    Download_Path = os.path.join( Download_Path, r'Comodo')
    if not os.path.exists(Download_Path):
        os.makedirs(Download_Path)
        print("Download path was created")
    if os.path.isdir(Download_Path):
        print('"' + Download_Path + '"' + " folder exists")
    else:
        print('"' + Download_Path + '"' + " folder do NOT exists")
    VerifyIfTheFileIsAlreadyPresentURL = os.path.join(Download_Path, fileNameURLverify)
    try:
        os.remove(VerifyIfTheFileIsAlreadyPresentURL)
    except OSError:
        pass
    pathURL = DownloadGoogle(Download_Path, Download_Application_Google, ApplicationFileNameGoogle,ApplicationExtensionGoogle)
    if ApplicationPackageIsGoogleVerifyDownload is "yes":
        pathURLfilesize = os.path.getsize(pathURL)
        if int(pathURLfilesize) == int(ApplicationPackageIsGoogleBytes):
            commandURL = ""
            if MSI is "yes":
                commandURL = 'msiexec /i "' + pathURL + '" ' + SwitchesMSI
                print('MSI command = ' + commandURL)
            if EXE is "yes":
                commandURL = '"' + pathURL + '" ' + SwitchesEXE
                print('EXE command = ' + commandURL)
            URLCommandResult = ecmd(commandURL, True)
            print(URLCommandResult)
            time.sleep(30)
            try:
                os.remove(VerifyIfTheFileIsAlreadyPresentURL)
            except OSError:
                pass
            if AppReboot is "yes":
                print(ecmd(r'shutdown.exe -r -t ' + AppRebootTime + ' /f /c "' + AppRebootComment + '"', True))
                print('System will restart in ' + AppRebootTime + ' seconds')
        else:
            print( fileNameURLverify + " was not copied successfully")
            print("We have " + pathURLfilesize + " bytes downloaded on the endpoint" )
            print("We need " + ApplicationPackageIsGoogleBytes + " bytes")
    else:
        commandURL = ""
        if MSI is "yes":
            commandURL = 'msiexec /i "' + pathURL + '" ' + SwitchesMSI
            print('MSI command = ' + commandURL)
        if EXE is "yes":
            commandURL = '"' + pathURL + '" ' + SwitchesEXE
            print('EXE command = ' + commandURL)
        URLCommandResult = ecmd(commandURL, True)
        print(URLCommandResult)
        time.sleep(30)
        try:
            os.remove(VerifyIfTheFileIsAlreadyPresentURL)
        except OSError:
            pass
        if AppReboot is "yes":
            print(ecmd(r'shutdown.exe -r -t ' + AppRebootTime + ' /f /c "' + AppRebootComment + '"', True))
            print('System will restart in ' + AppRebootTime + ' seconds')

def InstallApplicationSharedFolder(ApplicationPackageIsSharedFolderFolderPath, ApplicationFileNameSharedFolder, MSI, SwitchesMSI, EXE, SwitchesEXE, AppReboot, AppRebootTime, AppRebootComment):
    Download_Path = ""
    if ("7" in WindowsVersion or "2008 R2" in WindowsVersion or "Embedded" in WindowsVersion):
        Download_Path = os.environ['PROGRAMDATA']
    elif ("XP" in WindowsVersion or "2008" in WindowsVersion):
        Download_Path = os.environ['TEMP']
    else:
        Download_Path = os.environ['PROGRAMDATA']
    Download_Path = os.path.join( Download_Path, r'Comodo')
    if not os.path.exists(Download_Path):
        os.makedirs(Download_Path)
        print("Download path was created")
    if os.path.isdir(Download_Path):
        print('"' + Download_Path + '"' + " folder exists")
    else:
        print('"' + Download_Path + '"' + " folder do NOT exists")
    SP = os.path.join(ApplicationPackageIsSharedFolderFolderPath, ApplicationFileNameSharedFolder)
    print(SP)
    DP = os.path.join(Download_Path, ApplicationFileNameSharedFolder)
    print(DP)
    try:
        os.remove(DP)
    except OSError:
        pass
    import shutil
    shutil.copy(SP, DP)
    if os.path.getsize(SP) == os.path.getsize(DP):
        print("Installation files were copied successfully")
        commandURL = ""
        if MSI is "yes":
            commandURL = 'msiexec /i "' + DP + '" ' + SwitchesMSI
            print('MSI command = ' + commandURL)
        if EXE is "yes":
            commandURL = '"' + DP + '" ' + SwitchesEXE
            print('EXE command = ' + commandURL)
        URLCommandResult = ecmd(commandURL, True)
        print(URLCommandResult)
        time.sleep(30)
        try:
            os.remove(DP)
        except OSError:
            pass
        if AppReboot is "yes":
            print(ecmd(r'shutdown.exe -r -t ' + AppRebootTime + ' /f /c "' + AppRebootComment + '"', True))
            print('System will restart in ' + AppRebootTime + ' seconds')
    else:
        print("Installation files weren't copied")

if allowtorun==0:
    if VerifyIfApplication1IsPresent is "yes":
        if not Application1Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application1Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application1PackageIsURL is "yes":
                    InstallApplicationURL(Application1PackageURLX64, Application1PackageIsURLVerifyDownload, Application1PackageIsURLBytes, Application1InstallIsMSI, Application1MSISilentSwitches, Application1InstallIsEXE, Application1EXESilentSwitches, Application1Reboot, Application1RebootTime, Application1RebootComment)
                if Application1PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application1PackageGoogleX64, Application1FileNameGoogleX64, Application1ExtensionGoogleX64, Application1PackageIsGoogleVerifyDownload, Application1PackageIsGoogleBytes, Application1InstallIsMSI, Application1MSISilentSwitches, Application1InstallIsEXE, Application1EXESilentSwitches, Application1Reboot, Application1RebootTime, Application1RebootComment)
                if Application1PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application1PackageIsSharedFolderFolderPath, Application1FileNameSharedFolderX64, Application1InstallIsMSI, Application1MSISilentSwitches, Application1InstallIsEXE, Application1EXESilentSwitches, Application1Reboot, Application1RebootTime, Application1RebootComment)
            else:
                print("OS 32 bit")
                if Application1PackageIsURL is "yes":
                    InstallApplicationURL(Application1PackageURLX32, Application1PackageIsURLVerifyDownload, Application1PackageIsURLBytes, Application1InstallIsMSI, Application1MSISilentSwitches, Application1InstallIsEXE, Application1EXESilentSwitches, Application1Reboot, Application1RebootTime, Application1RebootComment)
                if Application1PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application1PackageGoogleX32, Application1FileNameGoogleX32, Application1ExtensionGoogleX32, Application1PackageIsGoogleVerifyDownload, Application1PackageIsGoogleBytes, Application1InstallIsMSI, Application1MSISilentSwitches, Application1InstallIsEXE, Application1EXESilentSwitches, Application1Reboot, Application1RebootTime, Application1RebootComment)
                if Application1PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application1PackageIsSharedFolderFolderPath, Application1FileNameSharedFolderX32, Application1InstallIsMSI, Application1MSISilentSwitches, Application1InstallIsEXE, Application1EXESilentSwitches, Application1Reboot, Application1RebootTime, Application1RebootComment)
            datenow1 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow1)
if allowtorun==0:
    if VerifyIfApplication2IsPresent is "yes":
        if not Application2Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application2Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application2PackageIsURL is "yes":
                    InstallApplicationURL(Application2PackageURLX64, Application2PackageIsURLVerifyDownload, Application2PackageIsURLBytes, Application2InstallIsMSI, Application2MSISilentSwitches, Application2InstallIsEXE, Application2EXESilentSwitches, Application2Reboot, Application2RebootTime, Application2RebootComment)
                if Application2PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application2PackageGoogleX64, Application2FileNameGoogleX64, Application2ExtensionGoogleX64, Application2PackageIsGoogleVerifyDownload, Application2PackageIsGoogleBytes, Application2InstallIsMSI, Application2MSISilentSwitches, Application2InstallIsEXE, Application2EXESilentSwitches, Application2Reboot, Application2RebootTime, Application2RebootComment)
                if Application2PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application2PackageIsSharedFolderFolderPath, Application2FileNameSharedFolderX64, Application2InstallIsMSI, Application2MSISilentSwitches, Application2InstallIsEXE, Application2EXESilentSwitches, Application2Reboot, Application2RebootTime, Application2RebootComment)
            else:
                print("OS 32 bit")
                if Application2PackageIsURL is "yes":
                    InstallApplicationURL(Application2PackageURLX32, Application2PackageIsURLVerifyDownload, Application2PackageIsURLBytes, Application2InstallIsMSI, Application2MSISilentSwitches, Application2InstallIsEXE, Application2EXESilentSwitches, Application2Reboot, Application2RebootTime, Application2RebootComment)
                if Application2PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application2PackageGoogleX32, Application2FileNameGoogleX32, Application2ExtensionGoogleX32, Application2PackageIsGoogleVerifyDownload, Application2PackageIsGoogleBytes, Application2InstallIsMSI, Application2MSISilentSwitches, Application2InstallIsEXE, Application2EXESilentSwitches, Application2Reboot, Application2RebootTime, Application2RebootComment)
                if Application2PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application2PackageIsSharedFolderFolderPath, Application2FileNameSharedFolderX32, Application2InstallIsMSI, Application2MSISilentSwitches, Application2InstallIsEXE, Application2EXESilentSwitches, Application2Reboot, Application2RebootTime, Application2RebootComment)
            datenow2 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow2)
if allowtorun==0:
    if VerifyIfApplication3IsPresent is "yes":
        if not Application3Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application3Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application3PackageIsURL is "yes":
                    InstallApplicationURL(Application3PackageURLX64, Application3PackageIsURLVerifyDownload, Application3PackageIsURLBytes, Application3InstallIsMSI, Application3MSISilentSwitches, Application3InstallIsEXE, Application3EXESilentSwitches, Application3Reboot, Application3RebootTime, Application3RebootComment)
                if Application3PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application3PackageGoogleX64, Application3FileNameGoogleX64, Application3ExtensionGoogleX64, Application3PackageIsGoogleVerifyDownload, Application3PackageIsGoogleBytes, Application3InstallIsMSI, Application3MSISilentSwitches, Application3InstallIsEXE, Application3EXESilentSwitches, Application3Reboot, Application3RebootTime, Application3RebootComment)
                if Application3PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application3PackageIsSharedFolderFolderPath, Application3FileNameSharedFolderX64, Application3InstallIsMSI, Application3MSISilentSwitches, Application3InstallIsEXE, Application3EXESilentSwitches, Application3Reboot, Application3RebootTime, Application3RebootComment)
            else:
                print("OS 32 bit")
                if Application3PackageIsURL is "yes":
                    InstallApplicationURL(Application3PackageURLX32, Application3PackageIsURLVerifyDownload, Application3PackageIsURLBytes, Application3InstallIsMSI, Application3MSISilentSwitches, Application3InstallIsEXE, Application3EXESilentSwitches, Application3Reboot, Application3RebootTime, Application3RebootComment)
                if Application3PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application3PackageGoogleX32, Application3FileNameGoogleX32, Application3ExtensionGoogleX32, Application3PackageIsGoogleVerifyDownload, Application3PackageIsGoogleBytes, Application3InstallIsMSI, Application3MSISilentSwitches, Application3InstallIsEXE, Application3EXESilentSwitches, Application3Reboot, Application3RebootTime, Application3RebootComment)
                if Application3PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application3PackageIsSharedFolderFolderPath, Application3FileNameSharedFolderX32, Application3InstallIsMSI, Application3MSISilentSwitches, Application3InstallIsEXE, Application3EXESilentSwitches, Application3Reboot, Application3RebootTime, Application3RebootComment)
            datenow3 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow3)
if allowtorun==0:
    if VerifyIfApplication4IsPresent is "yes":
        if not Application4Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application4Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application4PackageIsURL is "yes":
                    InstallApplicationURL(Application4PackageURLX64, Application4PackageIsURLVerifyDownload, Application4PackageIsURLBytes, Application4InstallIsMSI, Application4MSISilentSwitches, Application4InstallIsEXE, Application4EXESilentSwitches, Application4Reboot, Application4RebootTime, Application4RebootComment)
                if Application4PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application4PackageGoogleX64, Application4FileNameGoogleX64, Application4ExtensionGoogleX64, Application4PackageIsGoogleVerifyDownload, Application4PackageIsGoogleBytes, Application4InstallIsMSI, Application4MSISilentSwitches, Application4InstallIsEXE, Application4EXESilentSwitches, Application4Reboot, Application4RebootTime, Application4RebootComment)
                if Application4PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application4PackageIsSharedFolderFolderPath, Application4FileNameSharedFolderX64, Application4InstallIsMSI, Application4MSISilentSwitches, Application4InstallIsEXE, Application4EXESilentSwitches, Application4Reboot, Application4RebootTime, Application4RebootComment)
            else:
                print("OS 32 bit")
                if Application4PackageIsURL is "yes":
                    InstallApplicationURL(Application4PackageURLX32, Application4PackageIsURLVerifyDownload, Application4PackageIsURLBytes, Application4InstallIsMSI, Application4MSISilentSwitches, Application4InstallIsEXE, Application4EXESilentSwitches, Application4Reboot, Application4RebootTime, Application4RebootComment)
                if Application4PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application4PackageGoogleX32, Application4FileNameGoogleX32, Application4ExtensionGoogleX32, Application4PackageIsGoogleVerifyDownload, Application4PackageIsGoogleBytes, Application4InstallIsMSI, Application4MSISilentSwitches, Application4InstallIsEXE, Application4EXESilentSwitches, Application4Reboot, Application4RebootTime, Application4RebootComment)
                if Application4PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application4PackageIsSharedFolderFolderPath, Application4FileNameSharedFolderX32, Application4InstallIsMSI, Application4MSISilentSwitches, Application4InstallIsEXE, Application4EXESilentSwitches, Application4Reboot, Application4RebootTime, Application4RebootComment)
            datenow4 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow4)
if allowtorun==0:
    if VerifyIfApplication5IsPresent is "yes":
        if not Application5Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application5Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application5PackageIsURL is "yes":
                    InstallApplicationURL(Application5PackageURLX64, Application5PackageIsURLVerifyDownload, Application5PackageIsURLBytes, Application5InstallIsMSI, Application5MSISilentSwitches, Application5InstallIsEXE, Application5EXESilentSwitches, Application5Reboot, Application5RebootTime, Application5RebootComment)
                if Application5PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application5PackageGoogleX64, Application5FileNameGoogleX64, Application5ExtensionGoogleX64, Application5PackageIsGoogleVerifyDownload, Application5PackageIsGoogleBytes, Application5InstallIsMSI, Application5MSISilentSwitches, Application5InstallIsEXE, Application5EXESilentSwitches, Application5Reboot, Application5RebootTime, Application5RebootComment)
                if Application5PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application5PackageIsSharedFolderFolderPath, Application5FileNameSharedFolderX64,  Application5InstallIsMSI, Application5MSISilentSwitches, Application5InstallIsEXE, Application5EXESilentSwitches, Application5Reboot, Application5RebootTime, Application5RebootComment)
            else:
                print("OS 32 bit")
                if Application5PackageIsURL is "yes":
                    InstallApplicationURL(Application5PackageURLX32, Application5PackageIsURLVerifyDownload, Application5PackageIsURLBytes, Application5InstallIsMSI, Application5MSISilentSwitches, Application5InstallIsEXE, Application5EXESilentSwitches, Application5Reboot, Application5RebootTime, Application5RebootComment)
                if Application5PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application5PackageGoogleX32, Application5FileNameGoogleX32, Application5ExtensionGoogleX32, Application5PackageIsGoogleVerifyDownload, Application5PackageIsGoogleBytes, Application5InstallIsMSI, Application5MSISilentSwitches, Application5InstallIsEXE, Application5EXESilentSwitches, Application5Reboot, Application5RebootTime, Application5RebootComment)
                if Application5PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application5PackageIsSharedFolderFolderPath, Application5FileNameSharedFolderX32,  Application5InstallIsMSI, Application5MSISilentSwitches, Application5InstallIsEXE, Application5EXESilentSwitches, Application5Reboot, Application5RebootTime, Application5RebootComment)
            datenow5 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow5)
if allowtorun==0:
    if VerifyIfApplication6IsPresent is "yes":
        if not Application6Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application6Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application6PackageIsURL is "yes":
                    InstallApplicationURL(Application6PackageURLX64, Application6PackageIsURLVerifyDownload, Application6PackageIsURLBytes, Application6InstallIsMSI, Application6MSISilentSwitches, Application6InstallIsEXE, Application6EXESilentSwitches, Application6Reboot, Application6RebootTime, Application6RebootComment)
                if Application6PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application6PackageGoogleX64, Application6FileNameGoogleX64, Application6ExtensionGoogleX64, Application6PackageIsGoogleVerifyDownload, Application6PackageIsGoogleBytes, Application6InstallIsMSI, Application6MSISilentSwitches, Application6InstallIsEXE, Application6EXESilentSwitches, Application6Reboot, Application6RebootTime, Application6RebootComment)
                if Application6PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application6PackageIsSharedFolderFolderPath, Application6FileNameSharedFolderX64, Application6InstallIsMSI, Application6MSISilentSwitches, Application6InstallIsEXE, Application6EXESilentSwitches, Application6Reboot, Application6RebootTime, Application6RebootComment)
            else:
                print("OS 32 bit")
                if Application6PackageIsURL is "yes":
                    InstallApplicationURL(Application6PackageURLX32, Application6PackageIsURLVerifyDownload, Application6PackageIsURLBytes, Application6InstallIsMSI, Application6MSISilentSwitches, Application6InstallIsEXE, Application6EXESilentSwitches, Application6Reboot, Application6RebootTime, Application6RebootComment)
                if Application6PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application6PackageGoogleX32, Application6FileNameGoogleX32, Application6ExtensionGoogleX32, Application6PackageIsGoogleVerifyDownload, Application6PackageIsGoogleBytes, Application6InstallIsMSI, Application6MSISilentSwitches, Application6InstallIsEXE, Application6EXESilentSwitches, Application6Reboot, Application6RebootTime, Application6RebootComment)
                if Application6PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application6PackageIsSharedFolderFolderPath, Application6FileNameSharedFolderX32, Application6InstallIsMSI, Application6MSISilentSwitches, Application6InstallIsEXE, Application6EXESilentSwitches, Application6Reboot, Application6RebootTime, Application6RebootComment)
            datenow6 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow6)
if allowtorun==0:
    if VerifyIfApplication7IsPresent is "yes":
        if not Application7Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application7Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application7PackageIsURL is "yes":
                    InstallApplicationURL(Application7PackageURLX64, Application7PackageIsURLVerifyDownload, Application7PackageIsURLBytes, Application7InstallIsMSI, Application7MSISilentSwitches, Application7InstallIsEXE, Application7EXESilentSwitches, Application7Reboot, Application7RebootTime, Application7RebootComment)
                if Application7PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application7PackageGoogleX64, Application7FileNameGoogleX64, Application7ExtensionGoogleX64, Application7PackageIsGoogleVerifyDownload, Application7PackageIsGoogleBytes, Application7InstallIsMSI, Application7MSISilentSwitches, Application7InstallIsEXE, Application7EXESilentSwitches, Application7Reboot, Application7RebootTime, Application7RebootComment)
                if Application7PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application7PackageIsSharedFolderFolderPath, Application7FileNameSharedFolderX64, Application7InstallIsMSI, Application7MSISilentSwitches, Application7InstallIsEXE, Application7EXESilentSwitches, Application7Reboot, Application7RebootTime, Application7RebootComment)
            else:
                print("OS 32 bit")
                if Application7PackageIsURL is "yes":
                    InstallApplicationURL(Application7PackageURLX32, Application7PackageIsURLVerifyDownload, Application7PackageIsURLBytes, Application7InstallIsMSI, Application7MSISilentSwitches, Application7InstallIsEXE, Application7EXESilentSwitches, Application7Reboot, Application7RebootTime, Application7RebootComment)
                if Application7PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application7PackageGoogleX32, Application7FileNameGoogleX32, Application7ExtensionGoogleX32, Application7PackageIsGoogleVerifyDownload, Application7PackageIsGoogleBytes, Application7InstallIsMSI, Application7MSISilentSwitches, Application7InstallIsEXE, Application7EXESilentSwitches, Application7Reboot, Application7RebootTime, Application7RebootComment)
                if Application7PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application7PackageIsSharedFolderFolderPath, Application7FileNameSharedFolderX32, Application7InstallIsMSI, Application7MSISilentSwitches, Application7InstallIsEXE, Application7EXESilentSwitches, Application7Reboot, Application7RebootTime, Application7RebootComment)
            datenow7 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow7)
if allowtorun==0:
    if VerifyIfApplication8IsPresent is "yes":
        if not Application8Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application8Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print("OS 64 bit")
                if Application8PackageIsURL is "yes":
                    InstallApplicationURL(Application8PackageURLX64, Application8PackageIsURLVerifyDownload, Application8PackageIsURLBytes, Application8InstallIsMSI, Application8MSISilentSwitches, Application8InstallIsEXE, Application8EXESilentSwitches, Application8Reboot, Application8RebootTime, Application8RebootComment)
                if Application8PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application8PackageGoogleX64, Application8FileNameGoogleX64, Application8ExtensionGoogleX64, Application8PackageIsGoogleVerifyDownload, Application8PackageIsGoogleBytes, Application8InstallIsMSI, Application8MSISilentSwitches, Application8InstallIsEXE, Application8EXESilentSwitches, Application8Reboot, Application8RebootTime, Application8RebootComment)
                if Application8PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application8PackageIsSharedFolderFolderPath, Application8FileNameSharedFolderX64, Application8InstallIsMSI, Application8MSISilentSwitches, Application8InstallIsEXE, Application8EXESilentSwitches, Application8Reboot, Application8RebootTime, Application8RebootComment)
            else:
                print("OS 32 bit")
                if Application8PackageIsURL is "yes":
                    InstallApplicationURL(Application8PackageURLX32, Application8PackageIsURLVerifyDownload, Application8PackageIsURLBytes, Application8InstallIsMSI, Application8MSISilentSwitches, Application8InstallIsEXE, Application8EXESilentSwitches, Application8Reboot, Application8RebootTime, Application8RebootComment)
                if Application8PackageIsGoogle is "yes":
                    InstallApplicationGoogle(Application8PackageGoogleX32, Application8FileNameGoogleX32, Application8ExtensionGoogleX32, Application8PackageIsGoogleVerifyDownload, Application8PackageIsGoogleBytes, Application8InstallIsMSI, Application8MSISilentSwitches, Application8InstallIsEXE, Application8EXESilentSwitches, Application8Reboot, Application8RebootTime, Application8RebootComment)
                if Application8PackageIsSharedFolder is "yes":
                    InstallApplicationSharedFolder(Application8PackageIsSharedFolderFolderPath, Application8FileNameSharedFolderX32, Application8InstallIsMSI, Application8MSISilentSwitches, Application8InstallIsEXE, Application8EXESilentSwitches, Application8Reboot, Application8RebootTime, Application8RebootComment)
            datenow8 = datetime.datetime.now() + datetime.timedelta(minutes = int(min))
            WriteTimeStampToTheTimeStampFile(datenow8)
if allowtorun==0:
    if VerifyIfApplication9IsPresent is "yes":
        if not Application9Name in GetSoftwareUsingRegistryResult:
            allowtorun=1
            print ( Application9Name + ' is NOT present')
            OsPath = r"C:\Program Files (x86)"
            if os.path.exists(OsPath):
                print