Windows XP provides a VBS script to manage local and network printers from Windows command line. This script is Prnmngr.vbs and can be found in the directory C:\Windows\System32. Using this script, we can add or delete network printers and set or change default printer. Below you can find the syntax and use cases of this script along with some examples.
Add a network printer from windows command line
You can add a network printer by specifying the server name and printer name as in the below command.
cscript C:\windows\system32\prnmngr.vbs -p "printername" -s "servername"
Get the list of printers added to the system from Windows command line(CMD).
cscript C:\windows\system32\prnmngr.vbs -l
Get the default printer details from command line.
cscript C:\windows\system32\prnmngr.vbs -g
Example:
C:\>cscript C:\windows\system32\prnmngr.vbs -g
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
The default printer is \\printer01\LASERJET_8150PRINTER
C:\>
Set default printer from windows command line.
You can run the below command to set default printer.
cscript C:\windows\system32\prnmngr.vbs -t -p "\\Servername\printername"
For example, to set the printer laserjet_02 connected to the server \\printer02 as default, we need to run the below command.
cscript C:\windows\system32\prnmngr.vbs -t -p \\printer02\laserjet_02
Note that double quotes are not required if there is no space in the printer name.
Delete a network printer from windows command prompt:
cscript C:\windows\system32\prnmngr.vbs -d "\\servername\printername"
No comments:
Post a Comment