@htouvet,

Many thanks for all your help!!!

Below the final script version of full Installation and Uninstallation of the Miktex 2.9 software.

Code : Tout sélectionner

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

uninstallkey = []
destdir = makepath(programfiles,'MIKTEX')
startupdir = makepath(start_menu(1),"Programs","MiKTeX 2.9")

def install():
    print('Initializing installation of miktex.')
    mkdirs(destdir)
    install_exe_if_needed("basic-miktex-2.9.6643-x64.exe", timeout=2000, silentflags='--shared --unattended --common-install="%s"' % destdir)
    print('Installation OK!')
    try:
        print('Starting update miktex...')
        run(r'"%s"\miktex\bin\x64\mpm.exe --update --admin' % destdir, timeout=2000)
        print('Updated miktex OK!')
    except (RuntimeError, TypeError, NameError):
        raise

def uninstall():
    try:
        print('Starting miktex uninstall...')
        if iswin64():
            print('Uninstalling x64 version')
            run(r'"%s"\miktex\bin\x64\miktexsetup.exe --verbose --shared uninstall' % destdir, timeout=2000)
            remove_tree(destdir)
            print("%s" ' is removed successfully!' % destdir)
            remove_tree(startupdir)
            print("%s" ' is removed successfully!' % startupdir)
        else:
            print('Uninstalling x86 version')
            run(r'"%s"\miktex\bin\x64\miktexsetup.exe --verbose --shared uninstall' % destdir, timeout=2000)
            remove_tree(destdir)
            print("%s" ' is removed successfully!' % destdir)
            remove_tree(startupdir)
            print("%s" ' is removed successfully!' % startupdir)
        print('Uninstallation of miktex completed!')
    except (RuntimeError, TypeError, NameError):
        raise