Contactez nous

[RESOLVED] advanced *.exe install

Share here your tips or issues concerning WAPT Console or WAPT Agent / Venez ici partager vos problèmes et astuces concernants la console et l'agent WAPT
Règles du forum

* Questions can be asked in English or in French. If the thread is started in English, stick to English, if it is started in French, stick to French.
* Vous pouvez poser vos questions en Français ou en Anglais. Si un sujet est commencé en français, merci de répondre en français. Si un sujet est commencé en anglais, merci de répondre en anglais.

Hello wapters, :D

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 : Tout sélectionner

# -*- 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')
After installing your package, what is the output of the cmd command :

Code : Tout sélectionner

wapt-get list-registry miktex
Looking at https://tex.stackexchange.com/questions ... miktex-2-9, it looks like uninstall can be achieved with

Code : Tout sélectionner

uninstall_admin.exe
command.

So you could use this command in a uninstall() function in your package.

Something like :

Code : Tout sélectionner

def uninstall():
    run(makepath(programfilesx86,r'MiKTeX 2.9\miktex\bin\x64\internal\uninstall_admin.exe --unattended'))
After installing your package, what is the output of the cmd command :

Code : Tout sélectionner

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 : Tout sélectionner

Removed: cti_srt-miktexErrors: cti_srt-miktex
and in the client machine miktex does not uninstall.

If I manually execute the command:

Code : Tout sélectionner

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 may be like this?

Code : Tout sélectionner

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"'))
You have to find the proper unattended switch to append to

Code : Tout sélectionner

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...
According to the miktex developer, only have the uninstall option via commnad line with the installer itself.

Code : Tout sélectionner

miktexsetup uninstall
Tomorrow I'll try to remove it by running wmic through cmd.exe or rmdir in "C:\Program Files\MiKTeX 2.9".
I tried with the code below, but I get the error:

Code : Tout sélectionner

Coping miktexsetupx64.exe and miktexsetup.exe to MiKTeX 2.9 folder...
NameError: global name 'programfilesx86' is not defined

Code : Tout sélectionner

# -*- 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! :D
This looks fine,
just replace programfilesx86 in your code by programfiles32

Code : Tout sélectionner

# -*- 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!')
I change a litthe bit the script.

Code : Tout sélectionner

# -*- 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 occurs:
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 como um comando interno\r\nou externo, um programa oper\xc3\xa1vel ou um arquivo em lotes.\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?
Any feedback about my last question?
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 : Tout sélectionner

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