Option Explicit
On Error Resume Next
Dim Filename,Filename2,Exename,Path
Dim defPath,objProcList,objProcess
Dim strPrinterName,strdriverName,strPortName
Dim oExec
Set defPath = CreateObject("Scripting.FileSystemObject").GetFolder(".")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim fileNo
fileNo = 0
Filename = "X:\制造\KD04055-A906-A.pdf"
Filename2 = "X:\制造\KD04055-A906-a.pdf"
If fso.FileExists(Filename) or fso.FileExists(Filename2) Then
  fileNo = 1
End If
Filename = "X:\添附品\KD04055-A906-B.pdf"
Filename2 = "X:\添附品\KD04055-A906-b.pdf"
If fso.FileExists(Filename) or fso.FileExists(Filename2) Then
  fileNo = 1
End If
If fileNo = 0 Then
  WScript.Quit(0)
End If
Dim wShell : Set wShell=CreateObject("WScript.Shell")
Path=wShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\acrord32.exe\Path")
if Err.Number <> 0 then 
   WScript.Quit(3)
End if
wShell.CurrentDirectory = Path
Exename="AcroRd32.exe"
strPrinterName = "\\地址\ Print Driver"
strdriverName = "PrintUsage Universal Driver"
strPortName = ""
Dim objWshNetwork
Dim PName
Dim oClassSet,oClass,oLocator,oService
Set oLocator = WScript.CreateObject("WbemScripting.SWbemLocator")
Set oService = oLocator.ConnectServer
Set oClassSet = oService.ExecQuery("Select * From Win32_Printer")
strPrinterName = "\\地址\ Print Driver"
PName = "0"
For Each oClass In oClassSet
  If oClass.Caption = strPrinterName then
    PName = "1"
    Exit For
  End if
Next
If PName = "0" then 
WScript.Quit(4)
End if
Set oClassSet = Nothing
Set oClass = Nothing
Set oService = Nothing
Set oLocator = Nothing
Filename = "X:\print\KD04055-A906-A.pdf"
Filename2 = "X:\print\KD04055-A906-a.pdf"
If fso.FileExists(Filename) Then
  Set oExec=wShell.Exec( Exename & " /t /n " & " " & """" & Filename & """" & " " & """" &_ 
      strPrinterName  & """" & " " & """" & strdriverName & """" & " "  & """" & strPortName & """")
ElseIf fso.FileExists(Filename2) Then
  Set oExec=wShell.Exec( Exename & " /t /n " & " " & """" & Filename2 & """" & " " & """" &_ 
      strPrinterName  & """" & " " & """" & strdriverName & """" & " "  & """" & strPortName & """")
End if
if Err.Number <> 0 then 
  WScript.Quit 1931086030
End if
WScript.Sleep 1000
Filename = "X:\添附品\KD04055-A906-B.pdf"
Filename2 = "X:\添附品\KD04055-A906-b.pdf"
If fso.FileExists(Filename) Then
  Set oExec=wShell.Exec( Exename & " /t /n " & " " & """" & Filename & """" & " " & """" &_ 
      strPrinterName  & """" & " " & """" & strdriverName & """" & " "  & """" & strPortName & """")
ElseIf fso.FileExists(Filename2) Then
  Set oExec=wShell.Exec( Exename & " /t /n " & " " & """" & Filename2 & """" & " " & """" &_ 
      strPrinterName  & """" & " " & """" & strdriverName & """" & " "  & """" & strPortName & """")
End if
if Err.Number <> 0 then 
  WScript.Quit -1931086030
End if
WScript.Sleep 1000
Set defPath = Nothing
Set fso = Nothing
Set wShell = Nothing
WScript.Quit(0)