Code : Tout sélectionner
def uninstall_office_modules():
    print('Suppression des anciens modules office..')
    check_installed_soft = installed_softwares('Microsoft Office System')
    if check_installed_soft:
        for uninstall in check_installed_soft:
            key=uninstall['key']
            if installed_softwares(uninstallkey=key):
                cmd = WAPT.uninstall_cmd(uninstall['key'])
                run(cmd)
def uninstall_office365():
    print('Suppression Office 365')
    check_installed_soft = installed_softwares('office 365')
    if check_installed_soft:
        for uninstall in check_installed_soft:
            key=uninstall['key']
            if installed_softwares(uninstallkey=key):
                cmd = WAPT.uninstall_cmd(uninstall['key'])
                run(cmd)
mon def install ressemble à ça :
Code : Tout sélectionner
def install():
       	msoname = 'Microsoft Office Standard 2016'
        msoversion='16.0.4266.1001'
        check_installed_mso = installed_softwares(msoname)
        if not check_installed_mso:
            killsoft()
          
            uninstall_office_modules()
            uninstall_office365()
            
            print('Installation de Microsoft Office 2016')
            install_exe_if_needed('setup.exe',silentflags='/adminfile "silent.msp"',min_version=msoversion,key=None,timeout=1200)
            check_installed_out = installed_softwares(softname)
            if not check_installed_out:
             error('End audit did not find the software.')
