Page 1 of 2
[RESOLVED] advanced *.exe install
Published: April 18, 2018 - 2:15 PM
by empbilly
Hello wapters,
I am doing a custom setup.py for the installation of miktex software, but after installation I can't uninstall via wapt.
Does the code below need any extra configuration?
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
def install():
print('installing miktex v.2.9')
install_exe_if_needed("basic-miktex-2.9.6643-x64.exe",
silentflags="--shared --unattended"
key='MiKTeX 2.9')
Re: Advanced *.exe install
Published: April 18, 2018 - 4:02 PM
by htouvet
After installing your package, what is the output of the cmd command:
Looking at
https://tex.stackexchange.com/questions ... miktex-2-9, it looks like uninstall can be achieved with
command.
So you could use this command in an uninstall() function in your package.
Something like:
Code: Select all
def uninstall():
run(makepath(programfilesx86,r'MiKTeX 2.9\miktex\bin\x64\internal\uninstall_admin.exe --unattended'))
Re: Advanced *.exe install
Published: April 18, 2018 - 4:56 PM
by empbilly
After installing your package, what is the output of the cmd command:
Code: Select all
C:\Users\carinha>wapt-get list-registry miktex
UninstallKey Software
Version Uninstallstring
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
---------------------------------------
MiKTeX 2.9 MiKTeX 2.9
2.9 "C:\Program Files\MiKTeX 2.9\mi
ktex/bin/x64/internal\copystart_admin.exe" "C:\Program Files\MiKTeX 2.9\miktex/b
in/x64/internal\uninstall_admin.exe"
In the uninstallation of miktex informs that it is ok, but in the "summary" appears
Code: Select all
Removed: cti_srt-miktexErrors: cti_srt-miktex
and in the client machine miktex does not uninstall.
If I manually execute the command:
Code: Select all
C:\Program Files\MiKTeX 2.9\miktex\bin\x64\internal\uninstall_admin.exe --unattended
still the manual uninstallation window appears and does nothing automatic.
It might be like this
Code: Select all
def uninstall():
run(makepath(programfilesx86,r'"MiKTeX 2.9\mi
ktex/bin/x64/internal\copystart_admin.exe" "C:\Program Files\MiKTeX 2.9\miktex/b
in/x64/internal\uninstall_admin.exe"'))
Re: Advanced *.exe install
Published: April 18, 2018 - 5:35 PM
by htouvet
You have to find the proper unattended switch to append to
Code: Select all
C:\Program Files\MiKTeX 2.9\miktex\bin\x64\internal\uninstall_admin.exe
so that it runs silently. It may be /s /SILENT --quiet -q or perhaps it has not been planned to be ran silently at all ...
The command which is registered seems to be broken as there is mixup of backslashes and forward slashes...
Re: Advanced *.exe install
Published: April 19, 2018 - 12:34 AM
by empbilly
According to the miktex developer, only have the uninstall option via commnad line with the installer itself.
Tomorrow I'll try to remove it by running wmic through cmd.exe or rmdir in "C:\Program Files\MiKTeX 2.9".
Re: Advanced *.exe install
Published: April 19, 2018 - 5:43 PM
by empbilly
I tried with the code below, but I get the error:
Code: Select all
Coping miktexsetupx64.exe and miktexsetup.exe to MiKTeX 2.9 folder...
NameError: global name 'programfilesx86' is not defined
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
def install():
print('Coping miktexsetupx64.exe and miktexsetup.exe to MiKTeX 2.9 folder...')
filecopyto('miktexsetupx64.exe',makepath(programfilesx86,'MiKTeX 2.9'))
filecopyto('miktexsetup.exe',makepath(programfilesx86,'MiKTeX 2.9'))
if isfile(makepath(programfilesx86,'MiKTeX 2.9','miktexsetupx64.exe')):
print('Files copied successfully!')
print('Installing MiKTeX 2.9')
install_exe_if_needed("basic-miktex-2.9.6643-x64.exe", silentflags="--shared --unattended")
def uninstall():
print(u'Starting miktex uninstall...')
if iswin64():
print('Uninstalling x64 version')
run(makepath(programfilesx86,r'MiKTeX 2.9\miktexsetupx64.exe uninstall'))
else:
print('Uninstalling x86 version')
run(makepath(programfilesx86,r'MiKTeX 2.9\miktexsetup.exe uninstall'))
print(u'Uninstallation of MiKTeX 2.9 completed!')
I do not know if the "filetocopy" part works the way I think.
I copied the two files miktexsetupx64.exe and miktexsetup.exe into the package folder, as I show in the image below:
https://image.ibb.co/k22rU7/wapt_pkg.png (img tag not working?!)
Is that so?
How to fix this? If the code is bad, you can contribute!

Re: Advanced *.exe install
Published: April 19, 2018 - 7:26 PM
by htouvet
This looks fine
just replace programfilesx86 in your code by programfiles32
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
def install():
print('Coping miktexsetupx64.exe and miktexsetup.exe to MiKTeX 2.9 folder...')
filecopyto('miktexsetupx64.exe',makepath(programfiles32,'MiKTeX 2.9'))
filecopyto('miktexsetup.exe',makepath(programfiles32,'MiKTeX 2.9'))
if isfile(makepath(programfiles32,'MiKTeX 2.9','miktexsetupx64.exe')):
print('Files copied successfully!')
print('Installing MiKTeX 2.9')
install_exe_if_needed("basic-miktex-2.9.6643-x64.exe", silentflags="--shared --unattended")
def uninstall():
print(u'Starting miktex uninstall...')
if iswin64():
print('Uninstalling x64 version')
run(makepath(programfiles32,r'MiKTeX 2.9\miktexsetupx64.exe uninstall'))
else:
print('Uninstalling x86 version')
run(makepath(programfiles32,r'MiKTeX 2.9\miktexsetup.exe uninstall'))
print(u'Uninstallation of MiKTeX 2.9 completed!')
Re: Advanced *.exe install
Published: April 20, 2018 - 1:34 PM
by empbilly
I change a litthe bit the script.
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
destdir = makepath(programfiles32,'miktex_setup')
def install():
print('Coping miktexsetupx64.exe and miktexsetup.exe to MiKTeX 2.9 folder...')
mkdirs(destdir)
filecopyto('miktexsetupx64.exe',makepath(destdir,'miktexsetupx64.exe'))
filecopyto('miktexsetup.exe',makepath(destdir,'miktexsetup.exe'))
if isfile(makepath(programfiles32,'miktex_setup','miktexsetupx64.exe')):
print('Files copied successfully!')
print('Initializing installation of MiKTeX 2.9.')
install_exe_if_needed("basic-miktex-2.9.6643-x64.exe", silentflags="--shared --unattended")
def uninstall():
print(u'Starting miktex uninstall...')
if iswin64():
print('Uninstalling x64 version')
run(makepath(programfiles32,r'miktex_setup\miktexsetupx64.exe uninstall'))
remove_tree(destdir)
else:
print('Uninstalling x86 version')
run(makepath(programfiles32,r'miktex_setup\miktexsetup.exe uninstall'))
remove_tree(destdir)
print(u'Uninstallation of MiKTeX 2.9 completed!')
When I try to uninstall the mkitex, the below errors occur:
Starting miktex uninstall...
Uninstalling x64 version
'ascii' codec can't decode byte 0xc3 in position 132: ordinal not in range(128): faulty string is '"Command 'C:\\\\Program Files (x86)\\\\miktex_setup\\\\miktexsetupx64.exe uninstall' returned non-zero exit status 1.\nOutput:'C:\\Program' n\xc3\xa3o \xc3\xa9 reconhecido as an internal command\r\nou external, a program operation\xc3\xa1vel or an arquivo em lots.\r\n"'
Traceback (most recent call last):
File "c:\wapt\waptservice\waptservice.py", line 1151, in run
self.running_task.run()
File "c:\wapt\waptservice\waptservice_common.py", line 405, in pwrapper
return func(*arg, **kwargs)
File "c:\wapt\waptservice\waptservice_common.py", line 464, in run
self._run()
File "c:\wapt\waptservice\waptservice_common.py", line 912, in _run
self.result = self.wapt.remove(self.packagename,force=self.force)
File "c:\wapt\common.py", line 4377, in remove
logger.critical(u'Error running uninstall script: %s'%e)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 132: ordinal not in range(128)
Is the error on the part of miktex or wapt?
Re: Advanced *.exe install
Published: April 23, 2018 - 4:03 PM
by empbilly
Any feedback about my last question?
Re: Advanced *.exe install
Published: April 23, 2018 - 11:05 PM
by htouvet
Hi Empbilly,
There are 2 issues...
The first one is your code
The second one is my code...
As there are spaces in the program path you try to run, cmd expect that you place the path inside double quotes.
So there is a message telling that the program "c:\Program" does not exist.
Something like...
Code: Select all
def uninstall():
print(u'Starting miktex uninstall...')
if iswin64():
print('Uninstalling x64 version')
run(ur'"%s" uninstall' % makepath(programfiles32,'miktex_setup','miktexsetupx64.exe'))
remove_tree(destdir)
else:
print('Uninstalling x86 version')
run(ur'"%s" uninstall' % makepath(programfiles32,'miktex_setup','miktexsetup.exe'))
remove_tree(destdir)
print(u'Uninstallation of MiKTeX 2.9 completed!')
could work.
The second issue is that the error message is not plain ascii but encoded, and my code does not decode properly, thus the "'ascii' codec can't decode byte 0xc3 ..." second message