[SOLVED] The syntax for the file name... is incorrect

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
Règles du forum communautaire
* English support on www.reddit.com/r/wapt
* Le support communautaire en français se fait sur ce forum
* Merci de préfixer le titre du topic par [RESOLU] s'il est résolu.
* Merci de ne pas modifier un topic qui est taggé [RESOLU]. Ouvrez un nouveau topic en référençant l'ancien
* Préciser version de WAPT installée, version complète ET numéro de build (2.2.1.11957 / 2.2.2.12337 / etc.) AINSI QUE l'édition Enterprise / Discovery
* Les versions 1.8.2 et antérieures ne sont plus maintenues. Les seules questions acceptées vis à vis de la version 1.8.2 sont liés à la mise à jour vers une version supportée (2.1, 2.2, etc.)
* Préciser OS du serveur (Linux / Windows) et version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019)
* Préciser OS de la machine d'administration/création des paquets et de la machine avec l'agent qui pose problème le cas échéant (Windows 7 / 10 / 11 / Debian 11 / etc.)
* Eviter de poser plusieurs questions lors de l'ouverture de topic, sinon il risque d'être ignorer. Si plusieurs sujet, ouvrir plusieurs topic, et de préférence les uns après les autres et pas tous en même temps (ie ne pas spammer le forum).
* Inclure directement les morceaux de code, les captures d'écran et autres images directement dans le post. Les liens vers les pastebin, les bitly et autres sites tierces seront systématiquement supprimés.
* Comme tout forum communautaire, le support est fait bénévolement par les membres. Si vous avez besoin d'un support commercial, vous pouvez contacter le service commercial Tranquil IT au 02.40.97.57.55
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

25 sept. 2018 - 15:38

Hello,

I created a package to install surfer 11 software. In this package I also programmed the option to uninstall old versions before installing the new one.

After running on the client, the command output shows the error below:

Code : Tout sélectionner

Uninstalling old versions of surfer...
CalledProcessErrorOutput: Command [u'"C:\\ProgramData\\{5F3A4BBA-1519-45F2-9BF7-1E9924E32CAA}\\Surfer(11.1.719)_Installer.exe" REMOVE=TRUE MODIFY=FALSE'] returned non-zero exit status 1.
The syntax for the file name, directory name, or volume label is incorrect.
Package:

Code : Tout sélectionner

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

uninstallkey = []

destdir = makepath(programfiles, "Golden Software", "Surfer 11", "AppData")
filedir = "%s\\Gradient.ini" % destdir

def install():
    print('Uninstalling old versions of surfer...')
    for soft in installed_softwares('Surfer'):
        try:
            run(WAPT.uninstall_cmd(soft['key']))
        except ValueError:
            print('An error occured on Surfer unninstalling!')
    print('Uninstalling old versions of Surfer completed!')
    print('installing Surfer')
    install_msi_if_needed('surfer.msi')
    if os.path.exists(destdir):
        filecopyto("Gradient.ini", destdir)
    if os.path.exists(filedir):
        print("Gradient.ini copiado para %s" % destdir)
Avatar de l’utilisateur
htouvet
Expert WAPT
Messages : 402
Inscription : 16 mars 2015 - 10:48
Contact :

25 sept. 2018 - 15:46

Hello,
It's looks like uninstall_cmd returns a list which is not properly splitted.
run command can either tales a list or a str as first argument. In the case of a list, the first memeber of the list must be the executable and next members are the arguments of the command.
So if you get [u'"C:\\ProgramData\\{5F3A4BBA-1519-45F2-9BF7-1E9924E32CAA}\\Surfer(11.1.719)_Installer.exe" REMOVE=TRUE MODIFY=FALSE'] as return value of uninstall_cmd (ie a list with only one member), one way to workaround is to take first arg as cmd

Code : Tout sélectionner

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

uninstallkey = []

destdir = makepath(programfiles, "Golden Software", "Surfer 11", "AppData")
filedir = "%s\\Gradient.ini" % destdir

def install():
    print('Uninstalling old versions of surfer...')
    for soft in installed_softwares('Surfer'):
        try:
            cmd = WAPT.uninstall_cmd(soft['key'])
            if isinstance(cmd,list) and len(cmd) == 1:
                cmd = cmd[0]
            run(cmd)
        except ValueError:
            print('An error occured on Surfer unninstalling!')
    print('Uninstalling old versions of Surfer completed!')
    print('installing Surfer')
    install_msi_if_needed('surfer.msi')
    if os.path.exists(destdir):
        filecopyto("Gradient.ini", destdir)
    if os.path.exists(filedir):
        print("Gradient.ini copiado para %s" % destdir)
Tranquil IT
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

25 sept. 2018 - 17:05

hello htouvet, thanks for the answer!!!

I made the change, but a timeout error occurred.

I ran a test on the hand with the command below and silently removed.

Code : Tout sélectionner

C:\ProgramData\{5F3A4BBA-1519-45F2-9BF7-1E9924E32CAA}>"Surfer(11.1.719)_Installer.exe" REMOVE=TRUE SILENT=TRUE MODIFY=FALSE
How can I pass this option SILENT=TRUE as an argument?
Avatar de l’utilisateur
htouvet
Expert WAPT
Messages : 402
Inscription : 16 mars 2015 - 10:48
Contact :

25 sept. 2018 - 17:18

just append it to the command...

Code : Tout sélectionner

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

uninstallkey = []

destdir = makepath(programfiles, "Golden Software", "Surfer 11", "AppData")
filedir = "%s\\Gradient.ini" % destdir

def install():
    print('Uninstalling old versions of surfer...')
    for soft in installed_softwares('Surfer'):
        try:
            cmd = WAPT.uninstall_cmd(soft['key'])
            if isinstance(cmd,list) and len(cmd) == 1:
                cmd = cmd[0]
            if not 'SILENT=TRUE' in cmd:
                cmd = cmd + ' SILENT=TRUE'
            run(cmd)
        except ValueError:
            print('An error occured on Surfer unninstalling!')
    print('Uninstalling old versions of Surfer completed!')
    print('installing Surfer')
    install_msi_if_needed('surfer.msi')
    if os.path.exists(destdir):
        filecopyto("Gradient.ini", destdir)
    if os.path.exists(filedir):
        print("Gradient.ini copiado para %s" % destdir)
Tranquil IT
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

25 sept. 2018 - 17:51

Cool!!

But, if I execute manually via cmd the command:

Code : Tout sélectionner

C:\ProgramData\{5F3A4BBA-1519-45F2-9BF7-1E9924E32CAA}>"Surfer(11.1.719)_Installer.exe" REMOVE=TRUE MODIFY=FALSE SILENT=TRUE
is removed very fast.

Via script, the timeout error occurs. I config a timeout with 180 seconds, for test.

Code : Tout sélectionner

Uninstalling old versions of surfer...
TimeoutExpired: Command '"C:\ProgramData\{5F3A4BBA-1519-45F2-9BF7-1E9924E32CAA}\Surfer(11.1.719)_Installer.exe" REMOVE=TRUE MODIFY=FALSE SILENT=TRUE' timed out after 180 seconds with output ''''
Something wrong with my script?
Avatar de l’utilisateur
dcardon
Expert WAPT
Messages : 1373
Inscription : 18 juin 2014 - 09:58
Localisation : Saint Sébastien sur Loire
Contact :

26 sept. 2018 - 13:05

Hi Elias,
empbilly a écrit : 25 sept. 2018 - 17:51 But, if I execute manually via cmd the command:

Code : Tout sélectionner

C:\ProgramData\{5F3A4BBA-1519-45F2-9BF7-1E9924E32CAA}>"Surfer(11.1.719)_Installer.exe" REMOVE=TRUE MODIFY=FALSE SILENT=TRUE
is removed very fast.

Via script, the timeout error occurs. I config a timeout with 180 seconds, for test.

Code : Tout sélectionner

Uninstalling old versions of surfer...
TimeoutExpired: Command '"C:\ProgramData\{5F3A4BBA-1519-45F2-9BF7-1E9924E32CAA}\Surfer(11.1.719)_Installer.exe" REMOVE=TRUE MODIFY=FALSE SILENT=TRUE' timed out after 180 seconds with output ''''
Something wrong with my script?
Do you get this behavior when running the script in Pyscripter or throught WAPTService? If it works through PyScripter, then it might be an issue of running this command in "Local System" context (WaptService runs as "Local System").

Cheers,

Denis
Denis Cardon - Tranquil IT
Communiquez autour de vous sur WAPT! Envoyez nous vos url de blog et d'articles dans la catégorie votre avis du forum, nous les mettrons en avant sur le site WAPT
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

26 sept. 2018 - 14:17

Do you get this behavior when running the script in Pyscripter or throught WAPTService? If it works through PyScripter, then it might be an issue of running this command in "Local System" context (WaptService runs as "Local System").
I'm running throught WAPTService.

Is there any way to fix this issue?
Avatar de l’utilisateur
dcardon
Expert WAPT
Messages : 1373
Inscription : 18 juin 2014 - 09:58
Localisation : Saint Sébastien sur Loire
Contact :

26 sept. 2018 - 15:16

Hi Empbilly,
empbilly a écrit : 26 sept. 2018 - 14:17
Do you get this behavior when running the script in Pyscripter or throught WAPTService? If it works through PyScripter, then it might be an issue of running this command in "Local System" context (WaptService runs as "Local System").
I'm running throught WAPTService.

Is there any way to fix this issue?
You should try to run the uninstall binary in the "local system" context. For that you may install tis-ms-pstools and run

Code : Tout sélectionner

psexec -i -s cmd.exe
to get a shell as "local system". You can use the

Code : Tout sélectionner

whoami
to check if you are really running as SYSTEM. Then you run your uninstall binary.
If it works, you can then try to start pyscripter as "local system" and see if the package install goes through the same way as in your user context.

Cheers,

Denis
Denis Cardon - Tranquil IT
Communiquez autour de vous sur WAPT! Envoyez nous vos url de blog et d'articles dans la catégorie votre avis du forum, nous les mettrons en avant sur le site WAPT
empbilly
Messages : 79
Inscription : 15 janv. 2018 - 20:59

26 sept. 2018 - 18:53

dcardon,

How could I include "psexec ..." in the script above?
Avatar de l’utilisateur
dcardon
Expert WAPT
Messages : 1373
Inscription : 18 juin 2014 - 09:58
Localisation : Saint Sébastien sur Loire
Contact :

26 sept. 2018 - 19:44

Hi Elias,
empbilly a écrit : 26 sept. 2018 - 18:53 dcardon,

How could I include "psexec ..." in the script above?
you don't need to include psexec in setup.py. Psexec allows you to start a session as "Local System" and check if things are behaving differently when installing and uninstalling software.
You should just open a cmd.exe as administrator with elevated privileges (you can check with
whoami /groups
that you have the S-1-16-12288 security token at the end of the list). Then you type
psexec -i -s cmd.exe
and you should get another command prompt. In that command prompt you can type
whoami
to check that you are really "Local System" and then you are ready to go and test that the uninstall exe file is behaving correctly in that context.

Cheers,

Denis
Denis Cardon - Tranquil IT
Communiquez autour de vous sur WAPT! Envoyez nous vos url de blog et d'articles dans la catégorie votre avis du forum, nous les mettrons en avant sur le site WAPT
Verrouillé