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

Share your tips or issues concerning the WAPT Console or WAPT Agent here
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
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

September 25, 2018 - 3:38 PM

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: Select all

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: Select all

# -*- 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)
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

September 25, 2018 - 3:46 PM

Hello,
It's looks like uninstall_cmd returns a list which is not properly split.
run command can either tales a list or a str as first argument. In the case of a list, the first member 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: Select all

# -*- 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
Registration: January 15, 2018 - 8:59 PM

September 25, 2018 - 5:05 PM

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: Select all

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?
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

September 25, 2018 - 5:18 PM

just add it to the command...

Code: Select all

# -*- 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
Registration: January 15, 2018 - 8:59 PM

September 25, 2018 - 5:51 PM

Cool!!

But, if I execute manually via cmd the command:

Code: Select all

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 configure a timeout with 180 seconds, for test.

Code: Select all

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?
User avatar
dcardon
WAPT Expert
Messages: 1930
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

September 26, 2018 - 1:05 PM

Hi Elias,
empbilly wrote: September 25, 2018 - 5:51 PM But, if I execute manually via cmd the command:

Code: Select all

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 configure a timeout with 180 seconds, for test.

Code: Select all

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
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

September 26, 2018 - 2:17 PM

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?
User avatar
dcardon
WAPT Expert
Messages: 1930
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

September 26, 2018 - 3:16 PM

Hi Empbilly,
empbilly wrote: September 26, 2018 - 2:17 PM
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 can install tis-ms-pstools and run

Code: Select all

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

Code: Select all

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
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Empbilly
Messages: 79
Registration: January 15, 2018 - 8:59 PM

September 26, 2018 - 6:53 PM

dcardon,

How could I include "psexec ..." in the script above?
User avatar
dcardon
WAPT Expert
Messages: 1930
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

September 26, 2018 - 7:44 PM

Hi Elias,
empbilly wrote: September 26, 2018 - 6:53 p.m. 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
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Locked