Problem with --quiet argument and exit code in Powershell

387 views
Skip to first unread message

ARNascimento

unread,
Mar 13, 2013, 7:36:40 PM3/13/13
to jsig...@googlegroups.com

Hi Josef Cacef,

First of all, thank you for sharing this great tool.

I am trying to automate a process of signing some dozen PDFs that are created every month with a Powershell script, but am having two problems and was hoping you could help me.

First:     I don’t want to have info messages output to console, and have used argument –quiet, but, with this option, I am getting the following messages for every pdf signed:


log4j:WARN No appenders could be found for logger (net.sf.jsignpdf.SignerLogic).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.


Do you have any idea why? Do you have any suggestion to make it really quiet?


Second:  I would like to get the exit code from JSignPdfC.exe but I couldn’t get it. In case you can help me, I am enclosing the Powershell code I am using:

$arg1b = '--contact "Me" -d c:\temp -cl CERTIFIED_NO_CHANGES_ALLOWED --quiet -fs 5.0 -kst WINDOWS-MY -ka CPE -l London -r "Certify digital sign" -llx 385 -lly 780 -urx 583 -ury 820 -V'

 

$FiletoSign = "c:\temp\0560008167.pdf c:\temp\0563003516.pdf"

 

$rc = (Start-Process -FilePath  "C:\Program Files (x86)\JSignPdf\JSignPdfC.exe"  -ArgumentList "$FiletoSign $arg1b" -NoNewWindow -Wait).ExitCode

 

Write-Host " The process ended with Return code:" $rc

 

This returns “” (null) – the variable $rc is not set.

Nevertheless, if I use the line:

 

(Start-Process -FilePath "cmd.exe" -ArgumentList "/c echo foo" -Wait -Passthru).ExitCode

 

it returns 0 as echo is a recognized command, while the next line:

 

(Start-Process -FilePath "cmd.exe" -ArgumentList "/c ech foo" -Wait -Passthru).ExitCode

 

returns 1 because ech is not recognized.

Once again, can you help me, please?

 

Thanks in advance.

 

Américo Nascimento

Chris Hockaday

unread,
Jul 23, 2013, 7:24:55 AM7/23/13
to jsig...@googlegroups.com
Hi Américo

I have had success with exit codes by calling JSignPDF directly in PowerShell, instead of starting a process like you:

&"C:\Program Files (x86)\JSignPdf\JSignPdfC.exe" $if [...]

if ($?)
{
    "Success!"  
}
else
{
    "Something went wrong."
}
Reply all
Reply to author
Forward
0 new messages