Page 2 of 3

Re: OFFICE 2016 Package

Published: May 3, 2017 - 4:20 PM
by fludo67
I have two routines: one for Office 365 and one for Office add-ins (this has happened to me on quite a few machines with Office 2007: #error -2146368439)

Code: Select all

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)
There might be a cleaner way to do this by grouping all the routines into one with a for loop, but I went for the simplest approach.

My def install looks like this:

Code: Select all

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.')

Re: OFFICE 2016 Package

Published: May 3, 2017 - 4:27 PM
by Killian
fludo67 wrote:I have two routines: one for Office 365 and one for Office add-ins (this has happened to me on quite a few machines with Office 2007: #error -2146368439)

Code: Select all

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)
There might be a cleaner way to do this by grouping all the routines into one with a for loop, but I went for the simplest approach.

My def install looks like this:

Code: Select all

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.')
Thanks, my code looks like this, what do you think?

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():




    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)


    def killsoft():
      for soft in ('WINWORD.EXE','POWERPNT.EXE','EXCEL.exe','MSPUB.EXE','MSACCESS.EXE','INFOPATH.EXE','lync.exe','ONENOTE.EXE','OUTLOOK.EXE','ONENOTEM.EXE','MSOSYNC.EXE','GROOVE.EXE'):
        if isrunning(soft):
           print ("closing %s" % soft)
           killalltasks(soft)
    softname = 'Microsoft Office Professionnel Plus 2016'
    check_installed_out = installed_softwares(softname)

    print('installing Office 2016')
    if not check_installed_out:
            cmd = '"setup.exe" /adminfile "silent.msp"'
    else:
            cmd = 'msiexec.exe /p silent.msp'
    killsoft()
    uninstall_office_modules()
    uninstall_office365()
    run(cmd,timeout=1200,accept_returncodes=[1641,3010,0])
    check_installed_out = installed_softwares(softname)
    if not check_installed_out:
        error('End audit did not find the software.')

def uninstall():
    fichier = open("%s\silent.xml" % programfiles32, "w" )
    fichier.write('<Configuration Product="ProPlus"> \n')
    fichier.write('<Display Level="none" CompletionNotice="no" SuppressModal="yes" AcceptEula="yes" /> \n')
    fichier.write('   <Setting Id="SETUP_REBOOT" Value="NEVER" /> \n')
    fichier.write('</Configuration> \n')
    fichier.close()
    run('"%s\Common Files\microsoft shared\OFFICE16\Office Setup Controller\Setup.exe" /uninstall ProPlus /config "%s\silent.xml"' % (programfiles32,programfiles32),timeout=1200)
    remove_file(r'%s\silent.xml'% programfiles32)

Re: OFFICE 2016 Package

Published: May 3, 2017 - 4:36 PM
by fludo67
You need to call the functions you defined, and add them after killsoft()

Code: Select all

 
print('installing Office 2016')
    if not check_installed_out:
            cmd = '"setup.exe" /adminfile "silent.msp"'
    else:
            cmd = 'msiexec.exe /p silent.msp'
killsoft()
uninstall_office_modules()
uninstall_office_365()

Re: OFFICE 2016 Package

Published: May 3, 2017 - 4:37 PM
by Killian
fludo67 wrote:You need to call the functions you defined, and add them after killsoft()

Code: Select all

 
print('installing Office 2016')
    if not check_installed_out:
            cmd = '"setup.exe" /adminfile "silent.msp"'
    else:
            cmd = 'msiexec.exe /p silent.msp'
killsoft()
uninstall_office_modules()
uninstall_office_365()

Yes, I just noticed my mistake, so I edited my previous post

Re: OFFICE 2016 Package

Published: May 3, 2017 - 4:42 PM
by Killian
The installation finished with the code from the previous post:

Code: Select all

installing Office 2016
Suppression des anciens modules office..
Suppression Office 365
EWaptSetupException: Fatal error : End audit did not find the software.
Here's the error: even though Office is properly installed on the remote computer, how can I avoid this error?

Re: OFFICE 2016 Package

Published: May 3, 2017 - 4:59 PM
by fludo67
This is almost certainly related to the variable `softname = 'Microsoft Office Professional Plus 2016'`.

In your script, it checks for the software's presence after installation. If it doesn't find it, it generates this error. In the list of applications in Windows, is Office Professional Plus the version that was installed? (Check in Control Panel -> Apps -> and verify which version of Office was installed: Standard, Professional, etc.)

Re: OFFICE 2016 Package

Published: May 3, 2017 - 5:01 PM
by Killian
fludo67 wrote:It's probably related to the variable `softname = 'Microsoft Office Professional Plus 2016'`.

In your script, it checks for the software's presence after installation. If it doesn't find it, it generates this error. In the list of applications under Windows, is Office Professional Plus the one that was installed? (Check in Control Panel -> Apps -> and verify which version of Office was installed: Standard, Professional, etc.)
No, it's Standard

Re: OFFICE 2016 Package

Published: May 3, 2017 - 5:04 PM
by fludo67
You need to adapt the softname variable according to the version of Office you are installing.
In this case,

softname="microsoft office standard 2016"

Re: OFFICE 2016 Package

Published: May 4, 2017 - 8:48 AM
by Killian
fludo67 wrote:You need to adapt the softname variable according to the version of Office you install.
In this case,

softname="Microsoft Office Standard 2016"
Thank you so much! The problem is solved :)

Re: OFFICE 2016 Package

Published: May 5, 2017 - 1:59 PM
by Killian
Good morning,

I'm bringing this up again because I'd like to be able to uninstall Office 2016 from the WAPT console
here is my code

Code: Select all

def uninstall():
    fichier = open("%s\silent.xml" % programfiles32, "w" )
    fichier.write('<Configuration Product="ProPlus"> \n')
    fichier.write('<Display Level="none" CompletionNotice="no" SuppressModal="yes" AcceptEula="yes" /> \n')
    fichier.write('   <Setting Id="SETUP_REBOOT" Value="NEVER" /> \n')
    fichier.write('</Configuration> \n')
    fichier.close()
    run('"%s\Common Files\microsoft shared\OFFICE16\Office Setup Controller\Setup.exe" /uninstall ProPlus /config "%s\silent.xml"' % (programfiles32,programfiles32),timeout=1200)
    remove_file(r'%s\silent.xml'% programfiles32)