I'm trying to run a service on Vista that prints any pdf file dropped into a directory. The program works when started by hand.
When installed as service the print does not happen. I can see that AcroRd32 gets started but then hangs.### print files dropped into this directory use strict; use File::Copy; while(1) { opendir(DIRH, "c:\\printpdf") or die "couldn't open: $!"; open(FH, ">log.txt") or die "Cannot open log file"; foreach (readdir DIRH) { ### only take pdf files next unless /pdf$/i; ### acroread needs full path my $file = "c:\\PrintPDF\\$_"; print FH "Found $file\n"; #system "c:\\apps\\AcroRd32.lnk /p \"$file\""; system "c:\\apps\\AcroRd32.lnk /N /T \"$file\""; ### not sure how long acroread keeps the file open sleep 10; move("$_", "Done") or die "move failed: $!"; } close(FH); closedir(DIRH); sleep 30; }
I assume that is because a GUI program cannot be run as service.
I also tried a printing alternativ found on this site:
Same problem - works when started manually - hangs when started as service.use Win32::API; my $shellopen = new Win32::API("shell32", "ShellExecute", ['N', 'P', 'P', 'P', 'P', 'I'], 'N'); $shellopen->Call(0, "print", $file, 0, 0, 0);
Does anyone known a way to print PDFs w/o having to start any type of GUI application?
Thanx.
In reply to Printing PDFs as a windows service by stephanm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |