\\ Amazon冬支度セール 2024年11月4日 (水) ~ 11月12日 (火) 23:59 //

How to Use the prnport Command for TCP/IP Printer Port Management | Managing Printer Port Settings in Windows

The prnport command in Windows is used to create, delete, configure, and list standard TCP/IP printer ports from the command line. This tool is valuable for automating printer port management and streamlining network printer setup, particularly in enterprise or corporate network environments where multiple printers need to be managed efficiently.


目次

What is the prnport Command?

The prnport command allows you to manage TCP/IP printer ports in Windows. With it, you can create and delete standard TCP/IP ports, configure settings such as IP addresses, port numbers, and protocols, and even control SNMP settings. It is especially useful for administrators managing multiple network printers in complex environments.

Main Uses

  • Create/Delete TCP/IP Printer Ports: Set up or remove standard TCP/IP ports required for network printers.
  • List Printer Ports: Display all connected TCP/IP printer ports.
  • Configure Port Settings: Adjust IP addresses, port numbers, and protocols for printer ports.
  • Enable/Disable SNMP: Manage SNMP settings for printer ports to monitor network printer statuses.

How to Use the prnport Command

The prnport command enables efficient management of TCP/IP printer ports used by network printers. You can automate network printer setups and streamline the configuration process across multiple machines.

Basic Syntax

prnport [-a | -d | -l | -g | -t] [-s <Servername>] [-r <Portname>] [-o {raw|lpr}] [-h <Hostaddress>] [-n <Portnumber>] [-m {e|d}] [-i <SNMPindex>] [-y <Communityname>] [-u <Username> -w <Password>]
ParameterDescription
-aCreate a new TCP/IP printer port.
-dDelete an existing TCP/IP printer port.
-lList all TCP/IP printer ports on the system.
-gDisplay settings for a specified TCP/IP printer port.
-tConfigure settings for a specified TCP/IP printer port.
-s <Servername>Specify the remote computer hosting the printer. Defaults to the local machine if not specified.
-r <Portname>Required. Specify the name of the port to manage.
-o {raw | lpr}Specify the protocol to use (raw or lpr).
-h <Hostaddress>Specify the IP address of the printer to configure the port.
-n <Portnumber>Specify the port number (default is 9100).
-m {e | d}Enable or disable SNMP.
-i <SNMPindex>Specify the SNMP index (if SNMP is enabled).
-y <Communityname>Specify the SNMP community name (if SNMP is enabled).
-u <Username> -w <Password>Provide credentials to access the printer-hosting computer.
/?Display help for the command.

Example Usages

  1. Create a TCP/IP Printer Port
    Create a new standard TCP/IP printer port using a specified IP address and port number.
   prnport -a -r "IP_192.168.1.100" -h 192.168.1.100 -n 9100 -o raw

Description: This command creates a TCP/IP port for a network printer with IP address 192.168.1.100, using port 9100 and the raw protocol.

  1. Delete a TCP/IP Printer Port
    Remove an unused or obsolete TCP/IP printer port.
   prnport -d -r "IP_192.168.1.100"

Description: Deletes the TCP/IP port named IP_192.168.1.100.

  1. List All TCP/IP Printer Ports
    Display all TCP/IP printer ports currently configured on the local or remote computer.
   prnport -l

Description: Lists all TCP/IP printer ports on the local machine. Use the -s option to list ports on a remote server.

  1. View Port Configuration
    Display the configuration settings for a specified TCP/IP printer port.
   prnport -g -r "IP_192.168.1.100"

Description: Shows the current settings for the port IP_192.168.1.100.

  1. Change Port Protocol and Port Number
    Modify the protocol and port number for an existing TCP/IP printer port.
   prnport -t -r "IP_192.168.1.100" -o lpr -n 515

Description: Changes the protocol to lpr and sets the port number to 515 for the port IP_192.168.1.100.

SNMP Settings

The prnport command allows you to enable or disable SNMP (Simple Network Management Protocol) for printer ports and configure SNMP settings for network monitoring.

  1. Enable SNMP
    Enable SNMP with a specified community name and index for a TCP/IP port.
   prnport -t -r "IP_192.168.1.100" -m e -i 1 -y "public"

Description: Enables SNMP on the port IP_192.168.1.100 with SNMP index 1 and community name public.

  1. Disable SNMP
    Disable SNMP for a TCP/IP printer port.
   prnport -t -r "IP_192.168.1.100" -m d

Description: Disables SNMP for the port IP_192.168.1.100.

Practical Applications of the prnport Command

Automating Network Printer Setup Scripts

In environments with multiple network printers, the prnport command can be incorporated into scripts to automatically create and configure printer ports. This saves time when setting up new printers across a network.

@echo off
prnport -a -r "IP_192.168.1.100" -h 192.168.1.100 -n 9100 -o raw
prnport -a -r "IP_192.168.1.101" -h 192.168.1.101 -n 9100 -o raw

Description: This batch script automatically creates two TCP/IP printer ports for network printers with IP addresses 192.168.1.100 and 192.168.1.101.

Managing Remote Printer Ports

You can also manage printer ports on remote computers, making it easier for network administrators to configure and troubleshoot printer issues on different systems.

prnport -l -s \\server

Description: Lists all TCP/IP printer ports on the remote computer \\server, providing a clear overview of the ports in use.

Important Considerations

  • Administrator Privileges Required: Creating, deleting, or configuring printer ports requires administrator rights. Ensure that you run the command prompt as an administrator.
  • Correct IP Address: Ensure that you enter the correct IP address when setting up a port. Incorrect IP addresses will result in failed printer connections.
  • SNMP Settings: When enabling SNMP, ensure that the correct index and community name are configured for accurate network monitoring.

When to Use the prnport Command

The prnport command is useful for managing network printer TCP/IP ports efficiently. It is ideal for network administrators managing multiple printers across a network who need to create, configure, or remove ports, especially in large enterprise environments.

Conclusion

The prnport command is a powerful tool for managing TCP/IP printer ports in Windows, making it easier to configure and maintain network printer connections. Whether you’re managing a single printer or handling a large fleet of printers in a corporate environment, this command simplifies port setup and management. By integrating prnport into scripts, you can automate printer setup tasks and ensure consistent configuration across multiple systems.

Tamaglo

Thank you for reading!

Comments

To comment

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here

目次