2022年5月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
無料ブログはココログ

« Adobe Reader 8.1の起動オプション(その2) | トップページ | コマンドラインでPDFファイルを印刷する。(その2) »

2007年7月 2日 (月)

コマンドラインでPDFファイルを印刷する。

/cjsオプションが7.0で追加されたものの、8.1で廃止されたので、スクリプト。

Adobe Reader 6.0 - 8.1 用

PDF印刷.VBS PDFファイル...

Set fso=CreateObject("Scripting.FileSystemObject")
Set wShell=CreateObject("WScript.Shell")
Path=wShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\acrord32.exe\")
Path=Replace(Path,"""","")
Path=wShell.ExpandEnvironmentStrings(Path)
Printer=Split(wShell.RegRead("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"),",")(0)
Set PDF=CreateObject("AcroExch.Document")
For Each File In WScript.Arguments
  File=fso.GetFile(File).Path
'  Set PDF=GetObject(File)
  wShell.Run """"&Path&""" /n /t """&File&""" """&Printer&"""",,True
Next

Adobe Reader 7.0 - 8.1 用

PDF印刷.VBS PDFファイル...

Set fso=CreateObject("Scripting.FileSystemObject")
Set wShell=CreateObject("WScript.Shell")
Path=wShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\acrord32.exe\")
Path=Replace(Path,"""","")
Path=wShell.ExpandEnvironmentStrings(Path)
Set PDF=CreateObject("AcroExch.Document")
For Each File In WScript.Arguments
  File=fso.GetFile(File).Path
'  Set PDF=GetObject(File)
  wShell.Run """"&Path&""" /n /t """&File&"""",,True
Next

/tオプションは、他にAdobe Readerがないと、終了せずに残ります。
CreateObject("AcroExch.Document")や、GetObject(File)で、
Adobe Readerが起動し、参照の解放で終了することを利用します。
もし、CreateObjectが使えないときは、GetObjectに変えてください。
GetObjectだと、ちょっと遅いかも。

« Adobe Reader 8.1の起動オプション(その2) | トップページ | コマンドラインでPDFファイルを印刷する。(その2) »