Page 1 sur 2
[SOLVED] The syntax for the file name... is incorrect
Posté : 25 sept. 2018 - 15:38
par empbilly
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)
Re: The syntax for the file name... is incorrect
Posté : 25 sept. 2018 - 15:46
par htouvet
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)
Re: The syntax for the file name... is incorrect
Posté : 25 sept. 2018 - 17:05
par empbilly
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?
Re: The syntax for the file name... is incorrect
Posté : 25 sept. 2018 - 17:18
par htouvet
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)
Re: The syntax for the file name... is incorrect
Posté : 25 sept. 2018 - 17:51
par empbilly
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?
Re: The syntax for the file name... is incorrect
Posté : 26 sept. 2018 - 13:05
par dcardon
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
Re: The syntax for the file name... is incorrect
Posté : 26 sept. 2018 - 14:17
par empbilly
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?
Re: The syntax for the file name... is incorrect
Posté : 26 sept. 2018 - 15:16
par dcardon
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
to get a shell as "local system". You can use the
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
Re: The syntax for the file name... is incorrect
Posté : 26 sept. 2018 - 18:53
par empbilly
dcardon,
How could I include "psexec ..." in the script above?
Re: The syntax for the file name... is incorrect
Posté : 26 sept. 2018 - 19:44
par dcardon
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