Office 2016 Package

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
fludo67
Messages: 21
Registration: Sep 13, 2016 - 2:23 p.m.

May 3, 2017 - 4:20 PM

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.')
Killian
Messages: 38
Registration: May 3, 2017 - 11:19

May 3, 2017 - 4:27 PM

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)
fludo67
Messages: 21
Registration: Sep 13, 2016 - 2:23 p.m.

May 3, 2017 - 4:36 PM

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()
Killian
Messages: 38
Registration: May 3, 2017 - 11:19

May 3, 2017 - 4:37 PM

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
Killian
Messages: 38
Registration: May 3, 2017 - 11:19

May 3, 2017 - 4:42 PM

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?
fludo67
Messages: 21
Registration: Sep 13, 2016 - 2:23 p.m.

May 3, 2017 - 4:59 PM

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.)
Killian
Messages: 38
Registration: May 3, 2017 - 11:19

May 3, 2017 - 5:01 PM

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
fludo67
Messages: 21
Registration: Sep 13, 2016 - 2:23 p.m.

May 3, 2017 - 5:04 PM

You need to adapt the softname variable according to the version of Office you are installing.
In this case,

softname="microsoft office standard 2016"
Killian
Messages: 38
Registration: May 3, 2017 - 11:19

May 4, 2017 - 08:48

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 :)
Killian
Messages: 38
Registration: May 3, 2017 - 11:19

May 5, 2017 - 1:59 PM

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)
Locked