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)
vb.net 打印机代码 vbs打印
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
HP7740彩色打印机无法打印彩色,首选项报错
HP7740 无法打印彩色 首选项无法设置
首选项 无法打印彩色 HP7740 -
win10共享打印机给win7
win10共享打印机到win7
网络访问 win10 共享打印机 win7 -
vb.net模板打印源代码 vb如何实现打印
我们编程时,如果在程序中加入“打印”功能会使程序更加完善,更加专业。下面,我提供几种编写打印程序的方法以供大家参考。
vb.net模板打印源代码 Word 控件 应用程序 -
python 判断打印机 python打印机打印
Python print打印
python 判断打印机 字符串 IP 运算符