This VBscript will add one or more printers by using a subroutine. Tested on Windows 2000, XP, Vista & 7.
'==========================================================================
'AddPrinter.vbs
'By Timothy Bourne
'http://www.imric.co.uk
'Last Modified: 24th January 2010
'==========================================================================
'This VBscript will add one or more printers by using a subroutine.
'==========================================================================
Option Explicit
On Error Resume Next
Dim strPrinterPath
Dim objNetwork
'Path of Printer
strPrinterPath = "\\ServerName\Printer1"
AddPrinter
objNetwork.SetDefaultPrinter strPrinterPath 'Makes this printer the default.
WScript.Echo strPrinterPath & " was marked default."
strPrinterPath = "\\ServerName\Printer2"
AddPrinter
'Add a printer subroutine
Sub AddPrinter
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection strPrinterPath
WScript.Echo strPrinterPath & " was successfully mapped."
End Sub
No comments:
Post a Comment