#To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('parameterName') with that parameter's name URL_32='https://teams.microsoft.com/downloads/desktopurl?env=production&plat=windows&arch=&download=true'## Here mention the 32 bit download url URL_64='https://teams.microsoft.com/downloads/desktopurl?env=production&plat=windows&arch=x64&download=true'## Here mention the 64 bit download url import os import ctypes from subprocess import PIPE, Popen import ctypes if 'PROGRAMFILES(X86)' in os.environ.keys(): fromURL=URL_64 else: fromURL=URL_32 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) import subprocess import ssl with disable_file_system_redirection(): import urllib Down_path=os.environ['PROGRAMDATA'] fileName = 'Teams_windows.exe' DownTo = os.path.join(Down_path, fileName) def downloadFile(DownTo, fromURL): try: with open(DownTo, 'wb') as f: try: context = ssl._create_unverified_context() f.write(urllib.urlopen(fromURL,context=context).read()) except: f.write(urllib.urlopen(fromURL).read()) if os.path.isfile(DownTo): return '{} - {}KB'.format(DownTo, os.path.getsize(DownTo)/1000) except: return 'Please Check URL or Download Path!' if __name__=='__main__': print downloadFile(DownTo, fromURL ) fileName = 'Teams_windows.exe' print fileName INSTALLDIR=os.environ['PROGRAMFILES']+r'\Teams_windows' import shutil try: if os.path.exists(DownTo): print "check" ec='%s --silent'%(DownTo) print ec OBJ = Popen(ec, shell = True, stdout = PIPE, stderr = PIPE) out, err = OBJ.communicate() RET = OBJ.returncode if RET == 0: print "Microsoft Teams is installed" else: print "Microsoft Teams is not installed" else: print "Please check the path" except Exception as err : print err #if os.path.exists(DownTo): #os.remove(DownTo) download_path=os.path.join(os.environ['TEMP'], 'syspin.exe') fromURL='http://www.technosys.net/download.aspx?file=syspin.exe' import ctypes 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) import subprocess with disable_file_system_redirection(): import urllib import os import time def downloadFile(DownTo, fromURL): try: DownTo = download_path with open(DownTo, 'wb') as f: f.write(urllib.urlopen(fromURL).read()) if os.path.isfile(DownTo): return '{} - {}KB'.format(DownTo, os.path.getsize(DownTo)/1000) except: return 'Please Check URL or Download Path!' print downloadFile(download_path, fromURL ) os.chdir(os.path.join(os.environ['TEMP'])) from subprocess import PIPE, Popen time.sleep(300) path1 = os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop\Microsoft Teams.lnk') path2 = os.path.join(os.path.join(os.environ['USERPROFILE']), 'OneDrive\Desktop\Microsoft Teams.lnk') if os.path.exists(path1): obj = Popen(r'syspin "%s" "Pin to taskbar"'%path1, shell = True, stdout = PIPE, stderr = PIPE) else: obj = Popen(r'syspin "%s" "Pin to taskbar"'%path2, shell = True, stdout = PIPE, stderr = PIPE)