Partager via


Prnmngr.vbs

Adds, deletes, and lists printers or printer connections, in addition to setting and displaying the default printer. Used without parameters, prnmngr.vbs displays command-line help for the prnmngr.vbs command.

To add a local printer

Syntax

cscript prnmngr.vbs -a -p PrinterName [-s RemoteComputer] -m DriverName -r PortName [-u UserName -w Password]

Parameters

-a   : Required. Specifies that you want to add a local printer.

-s   RemoteComputer   : Specifies, by name, the remote computer to which you want to add a local printer. If you do not specify a computer, the printer is added to the local computer.

-p   PrinterName   : Required. Specifies, by name, the local printer that you want to add.

-m   DriverName   : Required. Specifies, by name, the driver for the local printer you want to add. Drivers are often named for the model of printer they support. See the printer documentation for more information.

-r   PortName   : Required. Specifies the port to which the printer is connected. If this is a parallel or a serial port, use the ID of the port (for example, LPT1 or COM1). If this is a TCP/IP port, use the port name that was specified when the port was added. For more information, see Related Topics.

-u   UserName   -w   Password   : Specifies an account with permissions to connect by using Windows Management Instrumentation (WMI) services to the computer to which you want to add a local printer. All members of the Administrators group for that computer have these permissions, but the permissions can also be granted to other users. If you do not specify an account, you must be logged on under an account with these permissions for the command to work. For more information on WMI, see Related Topics.

/? : Displays help at the command prompt.

Remarks

  • This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.

  • If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

Example

To add a printer named ColorPrinter_2 that is connected to LPT1 on the local computer and requires a printer driver called Color Printer Driver1, type:

cscript prnmngr.vbs -a -p ColorPrinter_2 -m "Color Printer Driver1" -r lpt1:

To add a printer connection

Syntax

cscript prnmngr.vbs -ac -p PrinterName 

Parameters

-ac   : Required. Specifies that you want to add a printer connection.

-p   PrinterName   : Required. Specifies, by name, the printer for which you want to add a connection.

/? : Displays help at the command prompt.

Remarks

  • This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.

  • If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

To delete a printer

Syntax

cscript prnmngr.vbs -d -p PrinterName [-u UserName -w Password] [-s RemoteComputer]

Parameters

-d   : Required. Specifies that you want to delete a printer.

-p   PrinterName   : Required. Specifies, by name, the printer that you want to delete.

-u   UserName   -w   Password   : Specifies an account with permissions to connect by using Windows Management Instrumentation (WMI) services to the computer from which you want to delete a printer. All members of the Administrators group for that computer have these permissions, but the permissions can also be granted to other users. If you do not specify an account, you must be logged on under an account with these permissions for the command to work. For more information on WMI, see Related Topics.

-s   RemoteComputer   : Specifies, by name, the remote computer to which you want to add a local printer. If you do not specify a computer, the printer is added to the local computer.

/? : Displays help at the command prompt.

Remarks

  • This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.

  • If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

Example

To delete the printer named ColorPrinter_2 from the remote computer named HRServer, type:

cscript prnmngr.vbs -d -s HRServer -p ColorPrinter_2

To delete all of the printers from a computer

Syntax

cscript prnmngr.vbs -x [-s RemoteComputer] [-u UserName] [-w Password]

Parameters

-x   : Required. Specifies that you want to delete all printers from a computer.

-s   RemoteComputer   : Specifies, by name, the remote computer from which you want to delete all printers. If you do not specify a computer, all printers are deleted from the local computer.

-u   UserName   -w   Password   : Specifies an account with permissions to connect by using Windows Management Instrumentation (WMI) services to the computer from which you want to delete all printers. All members of the Administrators group for that computer have these permissions, but the permissions can also be granted to other users. If you do not specify an account, you must be logged on under an account with these permissions for the command to work. For more information on WMI, see Related Topics.

/? : Displays help at the command prompt.

Remarks

  • This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.

  • If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

To display the default printer

Syntax

cscript prnmngr.vbs -g

Parameters

-g   : Required. Specifies that you want to display the default printer.

/? : Displays help at the command prompt.

Remarks

  • This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.

  • If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

To set the default printer

Syntax

cscript prnmngr.vbs -t -p PrinterName

Parameters

-t   : Required. Specifies that you want to set the default printer.

-p   PrinterName   : Required. Specifies, by name, the printer that you want to set as the default printer.

/? : Displays help at the command prompt.

Remarks

  • This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.

  • If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

To list all of the printers for a computer

Syntax

cscript prnmngr.vbs -l [-s RemoteComputer] [-u UserName -w Password]

Parameters

-l   : Required. Specifies that you want to list all the printers for a computer.

-s   RemoteComputer   : Specifies, by name, the remote computer for which you want to list printers. If you do not specify a computer, the printers added to the local computer are listed.

-u   UserName   -w   Password   : Specifies an account with permissions to connect by using Windows Management Instrumentation (WMI) services to the computer for which you want to list printers. All members of the Administrators group for that computer have these permissions, but the permissions can also be granted to other users. If you do not specify an account, you must be logged on under an account with these permissions for the command to work. For more information on WMI, see Related Topics.

/? : Displays help at the command prompt.

Remarks

  • This command starts a script that is located in the systemroot\system32 directory. You must type this command at a command prompt with that directory as the current directory, or you must type the full path to that directory at the beginning of the cscript command.

  • If the information that you supply contains spaces, use quotation marks around the text (for example, "Computer Name").

Formatting legend

Format

Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

Prncnfg.vbs

Prnjobs.vbs

Prndrvr.vbs

Prnport.vbs

Prnqctl.vbs

Command-line reference A-Z

Using the command-based script host (CScript.exe)

WMI overview

WMI overview