Linux-Noob Forums

Full Version: Simple ways to add an delete network printers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Adds a printer connection to a network printer. Script must be run on the local computer.

 

Copy and paste in notepad and save as {filename}.vbs

 

Set WshNetwork = CreateObject("WScript.Network")

WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"

WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"

 

Removes a printer connection to a network printer. Script must be run on the local computer.

 

Set WshNetwork = WScript.CreateObject("WScript.Network")

WshNetwork.RemovePrinterConnection "\\PrintServer1\Xerox300"

 

 

You can add these in batch scripting or logon scripting to aid in the adding and removal of printers.

 

add printer

rundll32 printui.dll,PrintUIEntry /in /n \\server1\1220C

 

delete printer

rundll32 printui.dll,PrintUIEntry /dn /n \\server1\PRT4

 

Example of login script that mapps drives and adds a printer:

net use * /delete /y

 

net use H: \\server1\%username%$ /PERSISTENT:NO

 

net use S: \\server1\shared /PERSISTENT:NO

 

rundll32 printui.dll,PrintUIEntry /in /n \\server1\1220C