Page 1 of 1

application.executeProgram

PostPosted: Wed Mar 02, 2022 5:05 pm
by garroyo
I am trying to run application.executeprogram, specifing the cmd as I would do in a console, but I can't pass it the parameters I want.
In the console the command is:
AFCL.exe sign -certgui -i c:\tmp\fich.xml -o c:\tmp\fich_s.xml -format XAdES -store windows -filter subject.contains:12710839G -xml -config "policyIdentifier=urn:ticketbai:dss:policy:1\npolicyDescription=TicketBAI sinadura-politika / Politica de firma TicketBAI\npolicyIdentifierHash=6NrKAm60o7u62FUQwzZew24ra2ve9PRQYwC21AM6In0=\n policyIdentifierHashAlgorithm=http://www.w3.org/2001/04/xmlenc#sha256 \n policyQualifier=https://www.gipuzkoa.eus/ticketbai/sinadura \n format=XAdES Enveloped"


The options or parameters that I can pass to AFCL.exe in cmd are:
-gui (Performs the operation with a graphical environment. It has priority over -certgui)
-certgui (Uses a graphical dialog for the selection of the signing certificate)
-i inputfile (Input file path)
-o outputfile (Output file path)
-algorithm algo (Signature Algorithm)
-format (Sets the signature format)
auto (Selection of format based on the input file)
cades (CAdES format)
pades (PAdES format)
xades (XAdES format)
invoicee (Electronic invoice signature)
ooxml (OOXML format)
odf (ODF Format)
-config extraParams (Properties in plain text with the configuration of the operation)
-store (Sets the key store. By default, the system one)
auto (System Key Store)
windows (Windows Key Store)
mac (Mac OS X Key Store)
mozilla (Mozilla Firefox Keystore)
ID (electronic ID)
pkcs12:p12file (PKCS#12 store. "p12file" is the store path)
pkcs11:p11file (PKCS#11 store. "p11file" is the driver path)
-password password (Sets the store password)
-alias alias (Alias ​​of the signing certificate)
-filter filter (Filter to select the signing certificate)
-xml (Formats the response as XML)


I would appreciate help to indicate the correct way to pass these possible parameters to the application.

Re: application.executeProgram

PostPosted: Fri Mar 04, 2022 11:26 am
by Manolo_Etec
Hi garroyo

At first glance I would put it like this...

application.executeProgram('AFCL.exe', ['sign ', '-certgu', '-i c:\\tmp\\fich.xml','-o c:\\tmp\\fich_s.xml', .......]);

Re: application.executeProgram

PostPosted: Fri Mar 04, 2022 2:39 pm
by ROCLASI
Hi garroyo,

application.executeProgram() takes the program name as a string and everything you add behind the program name as an array with strings.
This means that every argument that is separated by a space is one entry in the array.
So -o c:\tmp\fich_s.xml are 2 separate entries in the array.
And like Manuel already mentioned, all your backslashes need to be escaped with an extra backslash. Of course when you use \n as an argument then you shouldn't add the extra backslash.

Also the application name requires usually the full path the application.

Hope this helps.

Re: application.executeProgram

PostPosted: Sat Mar 05, 2022 10:41 am
by garroyo
OK thank you. i will try what you say