{"id":1163,"date":"2013-08-02T01:04:56","date_gmt":"2013-08-02T06:04:56","guid":{"rendered":"http:\/\/wildow.com\/?p=1163"},"modified":"2013-08-02T01:04:56","modified_gmt":"2013-08-02T06:04:56","slug":"adding-tcpip-printer-ports","status":"publish","type":"post","link":"https:\/\/wildow.com\/?p=1163","title":{"rendered":"Adding TCP\/IP printer ports"},"content":{"rendered":"<h1>Adding TCP\/IP printer ports<\/h1>\n<p>The following VBS script &#8220;addTcpipPort.vbs&#8221; adds a TCP\/IP printer port, which can be then used by a printer installation:<\/p>\n<p><a href=\"http:\/\/wpkg.org\/Printer_configuration\" target=\"_blank\">http:\/\/wpkg.org\/Printer_configuration<\/a><\/p>\n<p><!--more--><\/p>\n<div dir=\"ltr\">\n<div>\n<pre>Set args = WScript.Arguments\r\nprinterPortName = args.Item(0)\r\ntcpipAddress    = args.Item(1)\r\ntcpipPortNumber = args.Item(2)\r\nSet objWMIService = GetObject(\"winmgmts:\")\r\nSet objNewPort = objWMIService.Get _\r\n(\"Win32_TCPIPPrinterPort\").SpawnInstance_\r\nobjNewPort.Name = printerPortName\r\nobjNewPort.Protocol = 1\r\nobjNewPort.HostAddress = tcpipAddress\r\nobjNewPort.PortNumber = tcpipPortNumber\r\nobjNewPort.SNMPEnabled = False\r\nobjNewPort.Put_<\/pre>\n<\/div>\n<\/div>\n<p>Syntax:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>cscript addTcpipPort.vbs &lt;new port name&gt; &lt;printer address&gt; &lt;printer port&gt;<\/pre>\n<\/div>\n<\/div>\n<p>Usage example, add a new printer port named &#8220;printerport1&#8221; with IP address &#8220;192.168.1.2&#8221; and port number &#8220;9100&#8221;:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>cscript addTcpipPort.vbs printerport1 192.168.1.2 9100<\/pre>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h1>[<a title=\"Edit section: Removing Printers\" href=\"http:\/\/wpkg.org\/index.php?title=Printer_configuration&amp;action=edit&amp;section=2\">edit<\/a>] Removing Printers<\/h1>\n<p>Sometimes it is nice to clean out old printer entries, especially when deploying printer configurations for the first time. A hint from <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2005\/12\/01\/how-can-i-remove-all-the-local-printers-from-a-computer.aspx\" rel=\"nofollow\">http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2005\/12\/01\/how-can-i-remove-all-the-local-printers-from-a-computer.aspx<\/a> does the tick for you:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>strComputer = \".\"\r\nSet objWMIService = GetObject(\"winmgmts:\\\\\" &amp; strComputer &amp; \"\\root\\cimv2\")\r\n\r\nSet colInstalledPrinters =  objWMIService.ExecQuery _\r\n    (\"Select * from Win32_Printer Where Network = FALSE\")\r\n\r\nFor Each objPrinter in colInstalledPrinters\r\n    objPrinter.Delete_\r\nNext<\/pre>\n<\/div>\n<\/div>\n<h1>[<a title=\"Edit section: Adding Printers\" href=\"http:\/\/wpkg.org\/index.php?title=Printer_configuration&amp;action=edit&amp;section=3\">edit<\/a>] Adding Printers<\/h1>\n<p>When a new printer is configured on a server, it still has to be &#8220;installed&#8221; on a workstation.<\/p>\n<p>A simple way to do it is the usage of startup scripts: executed with Administrator or SYSTEM rights &#8211; to install a printer on a workstation, and, user logon scripts, to install a printer for a user.<\/p>\n<p>First, install a printer on a server and make sure it prints.<\/p>\n<p>If it prints, add a line like this to <code>\/home\/samba\/unattended\/packages\/wpkg\/wpkg-start.bat<\/code> (the batch file where the WPKG is started):<\/p>\n<div dir=\"ltr\">\n<div>\n<pre> rundll32 printui.dll,PrintUIEntry \/q \/y \/ga \/in \/n \\\\servername\\printername<\/pre>\n<\/div>\n<\/div>\n<p>with the appropriate servername and printername. Will set installed printer as default.<\/p>\n<p>This has a drawback, that it&#8217;ll be used by all machines and run with user permissions. If you are adding non-domain printer to workstation in domain, make sure that point and print <a href=\"http:\/\/support.microsoft.com\/kb\/319939\" rel=\"nofollow\">restrictions<\/a> are disabled.<\/p>\n<p>To install a printer on certain workstations only, a WPKG entry like below could be used:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;packages&gt;\r\n &lt;package id=\"printer\" name=\"room 17\" revision=\"1\" priority=\"0\" reboot=\"false\"&gt;\r\n &lt;check type=\"registry\" condition=\"equals\" path=\"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Connections\\,,servername,printername\\Server\" value=\"\\\\servername\" \/&gt;\r\n   &lt;install cmd=\"rundll32 printui.dll,PrintUIEntry \/ga \/n\\\\servername\\printername\" \/&gt;\r\n   &lt;install cmd=\"net stop spooler\" \/&gt;\r\n   &lt;install cmd=\"net start spooler\" \/&gt;\r\n   &lt;remove cmd=\"rundll32 printui.dll,PrintUIEntry \/gd \/n\\\\servername\\printername\" \/&gt;\r\n   &lt;remove cmd=\"net stop spooler\" \/&gt;\r\n   &lt;remove cmd=\"net start spooler\" \/&gt;\r\n   &lt;upgrade cmd=\"rundll32 printui.dll,PrintUIEntry \/ga \/n\\\\servername\\printername\" \/&gt;\r\n   &lt;upgrade cmd=\"net stop spooler\" \/&gt;\r\n   &lt;upgrade cmd=\"net start spooler\" \/&gt;\r\n &lt;\/package&gt;\r\n&lt;\/packages&gt;<\/pre>\n<\/div>\n<\/div>\n<h1>[<a title=\"Edit section: The lazy way\" href=\"http:\/\/wpkg.org\/index.php?title=Printer_configuration&amp;action=edit&amp;section=4\">edit<\/a>] The lazy way<\/h1>\n<p>&#8230; or you could use printmig (pre-vista only) &#8230; All you need to do is install the printers on one machine and export them from printmig&#8230; You will get a nice cab file this way&#8230;<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;packages&gt;\r\n\r\n\t&lt;package\r\n\t\tid=\"printer\"\r\n\t\tname=\"printer\"\r\n\t\trevision=\"0\"\r\n\t\treboot=\"postponed\"\r\n\t\tpriority=\"5\" \r\n\t\texecute=\"once\"&gt;\r\n\r\n\t\t&lt;install cmd=\"%SOFTWARE%\\printer\\printmig.exe -i -r\u00a0%SOFTWARE%\\printer\\printer.cab\" \/&gt;\r\n\t&lt;\/package&gt;\r\n\r\n&lt;\/packages&gt;<\/pre>\n<\/div>\n<\/div>\n<p>This won&#8217;t work for shared printers. ( However it works for IP printers.)<\/p>\n<p>More silent printer installation options <a href=\"http:\/\/www.msfn.org\/board\/lofiversion\/index.php\/t43120.html\" rel=\"nofollow\">here<\/a>.<\/p>\n<h1>[<a title=\"Edit section: Another lazy way (Vista)\" href=\"http:\/\/wpkg.org\/index.php?title=Printer_configuration&amp;action=edit&amp;section=5\">edit<\/a>] Another lazy way (Vista)<\/h1>\n<p>For Vista, you can migrate your printers with printbrm.<\/p>\n<p>&#8211; Open the Administrative Tools folder, and then click Print Management.<\/p>\n<p>&#8211; In the Print Management tree, right-click the name of the computer that contains the printer queues that you want to export, and then click Export printers to a file. This starts the Printer Migration Wizard.<\/p>\n<p>&#8211; On the Select the file location page, specify the location to save the printer settings, and then click Next to save the printers. For this example, it&#8217;ll be &#8220;printer_labo.export&#8221;. It contains a Brother HL-1470N printer.<\/p>\n<p>The deployement after that is:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;package\r\n\tid=\"labo-printer\" \r\n\tname=\"Labo Printer\" \r\n\trevision=\"1\" \r\n\tpriority=\"0\" \r\n\treboot=\"false\"&gt;\r\n\r\n &lt;check type=\"registry\" condition=\"equals\" path=\"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Printers\\Brother HL-1470N\\Name\" value=\"Brother HL-1470N\" \/&gt;\r\n   &lt;install cmd=\"c:\\windows\\system32\\spool\\tools\\printbrm.exe -r -f\u00a0%SOFTWARE%\\Printers\\printer_labo.export -O FORCE\" \/&gt;\r\n   &lt;install cmd='rundll32 printui.dll,PrintUIEntry \/y \/n \"Brother HL-1470N\"' \/&gt;\r\n &lt;\/package&gt;<\/pre>\n<\/div>\n<\/div>\n<h1>[<a title=\"Edit section: Lazy Way Windows 7\" href=\"http:\/\/wpkg.org\/index.php?title=Printer_configuration&amp;action=edit&amp;section=6\">edit<\/a>] Lazy Way Windows 7<\/h1>\n<p>For Windows 7, it is the pretty much the same as Vista you can migrate your printers with printbrm.<\/p>\n<p>&#8211; Open the Administrative Tools folder, and then click Print Management.<\/p>\n<p>&#8211; In the Print Management tree, right-click the name of the computer that contains the printer queues that you want to export, and then click Export printers to a file. This starts the Printer Migration Wizard.<\/p>\n<p>&#8211; On the Select the file location page, specify the location to save the printer settings, and then click Next to save the printers.<\/p>\n<p>For example our export is &#8220;BR-Prt-Smeagol.printExport&#8221;. It contains a HP Color Laserjet 3800 printer named Office Color Laserjet 3800 &#8211; Smeagol.<\/p>\n<p>The deployment after that is:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;package\r\n\tid=\"Printer Smeagol\"\r\n\tname=\"Office Printer - Smeagol\"\r\n\trevision=\"1.00\"\r\n\tpriority=\"0\"\r\n\treboot=\"false\"&gt;\r\n\r\n\t&lt;variable name=\"Printer\" value=\"Office Color Laserjet 3800 - Smeagol\" \/&gt;\r\n\t&lt;variable name=\"FileName\" value=\"BR-Prt-Smeagol.printerExport\" \/&gt;\r\n\r\n\t&lt;check\r\n\t\ttype=\"registry\"\r\n\t\tcondition=\"equals\"\r\n\t\tpath=\"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Printers\\%Printer%\\Name\"\r\n\t\tvalue=\"%Printer%\" \/&gt;\r\n\r\n &lt;install cmd='\"%WINDIR%\\system32\\spool\\tools\\printbrm.exe\" -r -f\u00a0%SOFTWARE%\\Printers\\%FileName% -O FORCE' \/&gt;<\/pre>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h3>[<a title=\"Edit section: NOTICE\" href=\"http:\/\/wpkg.org\/index.php?title=Printer_configuration&amp;action=edit&amp;section=7\">edit<\/a>] NOTICE<\/h3>\n<p>When exporting the .printerExport file, you can not export directly to the\u00a0%software%\\printers folder. You will need to export the file to your local hard drive first, then copy it to the network share. At least I have noticed this on my exports. Spent half a day figuring that out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding TCP\/IP printer ports The following VBS script &#8220;addTcpipPort.vbs&#8221; adds a TCP\/IP printer port, which can be then used by a printer installation: http:\/\/wpkg.org\/Printer_configuration<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1163","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1163"}],"version-history":[{"count":1,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1163\/revisions"}],"predecessor-version":[{"id":1164,"href":"https:\/\/wildow.com\/index.php?rest_route=\/wp\/v2\/posts\/1163\/revisions\/1164"}],"wp:attachment":[{"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wildow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}