Forum moved here!

Home / Printing ReturnCode is always 1


I try to print a PDF with -print-to-default. The documents always prints but I get exitCode 1 all the time.
A batch to reproduce is:

H:\PdfTest>type run.bat
“C:\Program Files\SumatraPDF\SumatraPDF.exe” -new-window -silent test.pdf -print-to-default
if errorlevel 1 echo “RC greater or equal one”


H:\PdfTest>“C:\Program Files\SumatraPDF\SumatraPDF.exe” -new-window -silent test.pdf -print-to-default

H:\PdfTest>if errorlevel 1 echo “RC greater or equal one”
“RC greater or equal one”



I always question why anyone would use -silent as it blocks any error messages. it is mainly there for continuous unattended stress testing.

However with or without -silent the result “should” be the same.

I also question why you are using -new-window ?, since that is only of use whilst viewing and not in any way useful to printing.

So I would thus reduce your command to the essential

"C:\Program Files\SumatraPDF\SumatraPDF.exe" -print-to-default test.pdf
if errorlevel 1 echo "RC greater or equal one"

However I see no reason why if as written above you see the “Failure message” since the basic errorlevel is obscure and feedback is

IF %ERRORLEVEL% NEQ 0 Echo Something was wrong, so I may not have printed !
IF %ERRORLEVEL% EQU 0 Echo Should have worked, unless the printer jammed etc.

I have not tested all versions so it helps if you state which one you are using (use help about), just in case there was a difference at some time.
here in addition to older ones I tested current version


Thank you very much for your help. That solved my problem.

It’s indeed the “-new-window” switch that causes the returncode of 1. I have removed it and it returns 0.

I have used version 3.1.2 64-bit. May be that’s the reason I get 1. Sorry, should have checked that
there is a newer version.

Anyway: Thank you very much for SumatraPDF. Greate Tool !