Remote Add Print Port/Set Default Printer
Our machines in the labs are all configured to print to a GoPrint server in the large lab. Sometimes, the large lab, where the GoPrint servers are physically located, will be occupied. In this case, we have to enable printing to a small HP LaserJet 5 in the small lab so users can still print. The first time we set this up, I needed to add the printer to each of the 15 machines in the small lab. Yet another opportunity for command line fun. Here is what I came up with.
First I had to setup the port on each machine using a snippet of vbscript found in Windows:
cscript prnport.vbs -s machine_name -a -r TCPIP -h xxx.xxx.xxx.xxx -o raw -n 9100
Where xxx.xxx.xxx.xxx is the IP address of the printer and machine_name is the name of the remote machine. The -s switch specifies the remote machine name. The -a switch specifies that we're creating a standard TCP/IP port. Switch -r specifies the name of the port, in this case simply TCPIP. IP address is set via the -h switch and the port type of RAW is configured with -o. Finally, -n sets the port used by Windows Standard Port Monitor (SPM) which is 9100 by default.
Now that the port was created on the machine of interest, I needed to add the actual printer instance. For this I used the built-in DLL "printui.dll" as such:
rundll32 printui.dll,PrintUIEntry /c\\machine_name /if /b "HP LaserJet 5" /f%windir%\inf\ntprint.inf /r "TCPIP" /m "HP LaserJet 5" /Y
This added a printer called HP LaserJet 5 to port TCPIP on the remote machine, installing drivers for an HP LaserJet 5 from the standard Windows ntprint.inf driver catalog, and set it as default printer.
Yay done.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home