Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for prnpdf9.bat

(view source code of prnpdf9.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4. VER | FIND.EXE "Windows NT" >NUL && GOTO Syntax
  5. SETLOCAL
  6.  
  7. :: Check cmmand line argument
  8. IF     "%~1"=="" GOTO Syntax
  9. IF NOT "%~4"=="" GOTO Syntax
  10. IF NOT "%~3"=="" IF /I NOT "%~3"=="/D" GOTO Syntax
  11. ECHO."%~1" | FIND "/" >NUL && GOTO Syntax
  12. ECHO."%~1" | FIND "?" >NUL && GOTO Syntax
  13. ECHO."%~1" | FIND "*" >NUL && GOTO Syntax
  14. IF /I NOT "%~3"=="/D" IF NOT EXIST "%~1" GOTO Syntax
  15.  
  16. SET Start=START /MIN ""
  17. IF /I "%~3"=="/D" SET START=ECHO
  18.  
  19. IF EXIST "%ProgramFiles%\Foxit Software\Foxit Reader\Foxit Reader.exe" (
  20. 	IF "%~2"=="" (
  21. 		%Start% "%ProgramFiles%\Foxit Software\Foxit Reader\Foxit Reader.exe" /p "%~1"
  22. 	) ELSE (
  23. 		%Start% "%ProgramFiles%\Foxit Software\Foxit Reader\Foxit Reader.exe" /t "%~1" "%~2"
  24. 	)
  25. ) ELSE (
  26. 	IF EXIST "%ProgramFiles%\Adobe\Reader 9.0\Reader\AcroRd32.exe" (
  27. 		IF "%~2"=="" (
  28. 			START /WAIT REGEDIT.EXE /E "%Temp%.\_DefPrn.dat" "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
  29. 			FOR /F "tokens=2 delims==" %%A IN ('TYPE "%Temp%.\_DefPrn.dat" ^| FINDSTR.EXE /R /B /I /C:"\"Device\"="') DO (
  30. 				FOR /F "delims=," %%B IN ("%%~A") DO (
  31. 					%Start% "%ProgramFiles%\Adobe\Reader 9.0\Reader\AcroRd32.exe" /N /T "%~1" "%%~B"
  32. 				)
  33. 			)
  34. 			DEL "%Temp%.\_DefPrn.dat"
  35. 		) ELSE (
  36. 			%Start% "%ProgramFiles%\Adobe\Reader 9.0\Reader\AcroRd32.exe" /N /T "%~1" "%~2"
  37. 		)
  38. 	)
  39. )
  40.  
  41. :: Done
  42. GOTO End
  43.  
  44.  
  45. :Syntax
  46. ECHO.
  47. ECHO PrnPDF9.bat,  Version 1.00 for Windows XP
  48. ECHO Prints a PDF file from the command line
  49. ECHO.
  50. ECHO Usage:  PRNPDF9  pdf_file  [ printer_name  [ /D ] ]
  51. ECHO.
  52. ECHO Where:  "pdf_file"      is the file name of the PDF file to be printed
  53. ECHO         "printer_name"  is the name of the printer to be used (optional)
  54. ECHO         /D              (Debug) only displays the selected print command
  55. ECHO.
  56. ECHO Notes:  Use double quotes for long file and printer names.
  57. ECHO         This batch file requires Adobe Reader 9.0+ or Foxit Reader 3.0+.
  58. ECHO         Foxit Reader will be used if found, otherwise Adobe Reader.
  59. ECHO         If Adobe Reader is used, at least 1 Adobe Reader window will be
  60. ECHO         left open, Foxit Reader will always terminate after printing.
  61. ECHO         To debug the print command, use "" for the default printer.
  62. ECHO         Download location Adobe Reader:
  63. ECHO         http://get.adobe.com/reader/
  64. ECHO         Download location Foxit Reader:
  65. ECHO         http://www.foxitsoftware.com/pdf/reader/download.php
  66. ECHO.
  67. ECHO Written by Rob van der Woude
  68. ECHO http://www.robvanderwoude.com
  69.  
  70.  
  71. :End
  72. IF "%OS%"=="Windows_NT" ENDLOCAL
  73.  

page last modified: 2024-04-16; loaded in 0.0052 seconds