Avatar of deibel
deibelFlag for Germany

asked on 

Print PDF as custom service SBS2008

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
Windows Server 2008Programming

Avatar of undefined
Last Comment
deibel
Avatar of dj_alik
dj_alik

did you try
/t <filename> <printername> <drivername> <portname> - Print the file the specified printer.
Avatar of dj_alik
dj_alik

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"
Avatar of deibel
deibel
Flag of Germany image

ASKER

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?
Avatar of deibel
deibel
Flag of Germany image

ASKER

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

:-(
Avatar of deibel
deibel
Flag of Germany image

ASKER

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....
Avatar of dj_alik
dj_alik

can you try to run this manually on SBS2008 ?
and  run "NET USE"  on SBS2008  to see  all available printers.
Avatar of deibel
deibel
Flag of Germany image

ASKER

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
Avatar of deibel
deibel
Flag of Germany image

ASKER

is there any other programm that can print PDF from command line that doesnt depend on acrord?
ASKER CERTIFIED SOLUTION
Avatar of dj_alik
dj_alik

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of deibel
deibel
Flag of Germany image

ASKER

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
Avatar of deibel
deibel
Flag of Germany image

ASKER

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
Windows Server 2008
Windows Server 2008

Windows Server 2008 and Windows Server 2008 R2, based on the Microsoft Vista codebase, is the last 32-bit server operating system released by Microsoft. It has a number of versions, including including Foundation, Standard, Enterprise, Datacenter, Web, HPC Server, Itanium and Storage; new features included server core installation and Hyper-V.

86K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo