Logon script add printer


Recommended Posts

Two ways to do this:

1. Command Script (Batch File): Use rundll32 printui,PrintUIEntry, run rundll32 printui,PrintUIEntry /? to see available options, which include adding printers, removing printers and setting the default printer.

rundll32 printui,PrintUIEntry /in /n\\SERVER\PRINTERSHARE

2. VBScript. Listed below are three functsion you can use for adding printers, removing printers and setting the default printer.

Function fnRemoveAllPrinterConnections (ServerName)
	Dim i, oPrinters
	Set oPrinters = WshNetwork.EnumPrinterConnections
	For i = 0 to oPrinters.Count - 1 Step 2
  If InStr(UCase(oPrinters.Item(i+1)), UCase(ServerName)) Then
 	 WshNetwork.RemovePrinterConnection oPrinters.Item(i+1)
  End If
	Next  
	Set i = Nothing
	Set oPrinters = Nothing
End Function

' --------------------------
Function fnAddPrinterConnection (PrinterPath)
	WshNetwork.AddWindowsPrinterConnection PrinterPath
End Function

' --------------------------
Function fnSetDefaultPrinter (PrinterPath)
	WshNetwork.SetDefaultPrinter PrinterPath
End Function

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.