我正在使用以下VBScript设置默认打印机:
Option Explicit
On Error Resume Next
Dim objNetwork, strUNCPrinter
strUNCPrinter = "\\printer\location\here"
Set objNetwork = CreateObject("WScript.Network")
objNetwork.SetDefaultPrinter strUNCPrinter
WScript.Quit
我想要做的是循环打印机,基本上“如果没有安装此打印机,请将其设为默认打印机”
我已经尝试过重复脚本,祈祷它会重复这个过程,但它只是错误。
答案 0 :(得分:1)
您可以尝试使用此代码:
Option Explicit
On Error Resume Next
Dim objNetwork, strUNCPrinter
strUNCPrinter = "\\printer\location\here"
Set objNetwork = CreateObject("WScript.Network")
Set objAdd = objNetwork.AddWindowsPrinterConnection(strUNCPrinter)
If Not objAdd Then
MsgBox "Printer connection unsuccessful"
Else
objNetwork.SetDefaultPrinter strUNCPrinter
End IF
Set objAdd = Nothing
Set objNetwork = Nothing