Print PDF as custom service SBS2008

deibel
deibel used Ask the Experts™
on
Hi Experts,

I need your advice!

I want to print a PDF from a SBS2008 periodical once a day.
The PDF is created by another application and saved in a local folder.
This little "printservice" has to run in background with no user activity an also with no user logged into the machine.

I wrote a batchfile and configured the taskplaner to execute it.
but that doesnt work with no user logged into the machine.

so i thought i need a custom service and created one with srvany.exe
i modified the batch to an infinite loop
but that didnt work either.

This is my batchfile:
:START
start runas /profile /savecred /user:sysadmin@domain.local "C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe /p /h c:\test\Test.pdf"
@time /T>> c:\test\test.txt
timeout /T 300
Taskkill /F /IM acrord32.exe /T

goto START

I saw, that no printer is given as argument to AcroRd32 /p so i thought it only prints to the default printer. But there is no default printer, when no user is logged in. So I tried runas with no effect.

I googled a bit an read somthing about missing rights. But I dont really understand that.

Can anybody give me an advice?

Thanks in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011

Commented:
did you try
/t <filename> <printername> <drivername> <portname> - Print the file the specified printer.
Top Expert 2011

Commented:
found  example
D:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" /t "D:\R104-20071025165656.pdf" "\\192.168.0.4\hp" "hp LaserJet 1000" "\\192.168.0.4\hp"

Author

Commented:
no i did not.
/t is an argument for acrord32 ?

the printer is a network printer, that is locally installed on the server.
i mean, that it is not a network printer shared by a different printserver.

what do i have to type for drivername and portname?
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Top Expert 2011

Commented:

Author

Commented:
ok, i already googled that and use the following command:
"C:\Program Files (x86)\Adobe\Reader 9.0\Reader\AcroRd32.exe" /t "c:\test\test.pdf" "\\192.168.40.107\CM1312nfi" "HP Universal Printing PCL 6" "\\192.168.40.107\CM1312nfi"

but still the same. when i type it to cmd, it works
but when i start my batch file as service it doesnt

:-(

Author

Commented:
wait, i can see in taskmgr, that acrord32 is started, when i start my service.
but i cant see a printjob in the spooler of the laserjet.
i call the user to ask if something comes out of the printer.....maybe....
Top Expert 2011

Commented:
can you try to run this manually on SBS2008 ?
and  run "NET USE"  on SBS2008  to see  all available printers.

Author

Commented:
This is my new batchfile:

:START
start /D "C:\Program Files (x86)\Adobe\Reader 9.0\Reader" AcroRd32.exe /t "c:\test\test.pdf" "\\192.168.40.107\CM1312nfi" "HP Universal Printing PCL 6" "\\192.168.40.107\CM1312nfi"
@time /T>> c:\test\test.txt
timeout /T 60
Taskkill /F /IM acrord32.exe /T
timeout /T 60

goto START

i can start it manually and it works fine.
acrord opens a windows, a printjob appears in the spooler, acrord is closed and so on.

when i start it as service, i can see in taskmgr, that acrord32 ist started and killed after a minute.
but i dont see a printjob in the spooler and cant reach the user yet to ask him.

net use says: new connections will be saved, no entries in the list (translated orig. german)

192.168.40.107 in the acrord32 command is the server itself

Author

Commented:
is there any other programm that can print PDF from command line that doesnt depend on acrord?
Top Expert 2011
Commented:
i think your problem in security to access to printer.
another program will not solve your ptoblem
If printer is network try to define it locally in server machine.

Author

Commented:
it is locally as i mentioned above.
i found a tool defprint, that can define default printer from command line
i give it a try

Author

Commented:
i got it.
there is no printer in the environment, if the batchfile is executed as service with no user logged in.
so i added Rundll32 printui.dll,PrintUIEntry /ga /n\\SBS2008\CM1312nfi to the batchfile and it works.

i will award the points, because the /t argument was useful as well.
thanks for your help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial