Scripts to manage local printers. Setting up printers is usually done with the "add printer" wizzard.
This wizzard (apparently) uses code from a library, printui.dll. With the RUNDLL32 command it is possible to execute code from the dll, thus enabling us to do from the command line anything the Add Printer Wizzard can do, and - even better - create batch processes to set up multiple printers in seconds, and repeat an identical configuration on multiple computers. With RUNDLL32 PRINTUI.DLL we can install printer drivers install local printers share local printers connect to remote, shared printers connect remote printers to local TCP/IP ports - if they already exist (re. Set up TCP IP Printer Ports) However, we will focus on local printers, e.g. for the automatic setup of a (print) server, a set of workstations that require local printers for whatever reasons, or for local printers that connect directly to a networkprinter through a tcp/ip printerport.
The rundll32 printui.dll,PrintUIEntry statement Sharing a printer New ! Rundll32 printui.dll,PrintUIEntry. How To Install A Printer Using VBscript. The following guide is designed for IT administrators who want to automate the process of adding printers for multiple users.
Print Manager VBS script is built into windows to allow IT administrations the ability to add printers to client’s computers either based on group or security permissions. There are a few ways you can implement your vbscript, Through GPO and a Windows 2003 / 2008 Domain or by creating a simple bath file or executing from command prompt Prnmngr.vbs is the Cscript you will be using, it has the abilities to add, delete and list printers or printer connections, in addition to setting and displaying the default printers Below are some examples of how to use prnmngr.vbs. Syntax Cscript Prnmngr {-a | -d | -x | -g | -t | -l | -?}
Parameters Examples – The below example describes how to add the Lexmark T650 as your default printer. CSCRIPT %windir%\system32\prnmngr.vbs -t -p \\domain.local\Lexmark T650 (CompLab) Run Method (Windows Script Host) Runs a program in a new process. object .Run(strCommand, [intWindowStyle], [bWaitOnReturn]) object WshShell object. strCommand String value indicating the command line you want to run. IntWindowStyle Optional. bWaitOnReturn Optional. The Run method returns an integer. The following VBScript code opens a copy of the currently running script with Notepad. Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "%windir%\notepad " & WScript.ScriptFullName. WshNetwork Object. Provides access to the shared resources on the network to which your computer is connected.
You create a WshNetwork object when you want to connect to network shares and network printers, disconnect from network shares and network printers, map or remove network shares, or access information about a user on the network. The following example demonstrates displaying the domain name, computer name, and user name for the current computer system using the WshNetwork object.