viewpoint-particle

Author Topic: adding a printer by IP  (Read 74 times)

neshelman

  • Newbie
  • *
  • Posts: 2
adding a printer by IP
« on: October 24, 2018, 03:28:37 pm »
Is it possible to add a default printer by IP rather than name of a printer on a print server? Thanks --Nicholas

td

  • Tech Support
  • *****
  • Posts: 2618
    • WinBatch
Re: adding a printer by IP
« Reply #1 on: October 25, 2018, 08:23:42 am »
I don't have an answer and as it always seems to be the case, the answer likely depends on the unmentioned details.  First, you are asking about creating a WinBatch script to perform this task?  If so then are you referring to a printer connected to a server or a printer connected directly to the network?

That said, WinBatch does have a Printer Extender, IPGrabber, and Network Extender that one or more of which could potentially be used in some fashion to create a script that accomplishes your task.   You might want to peruse the documentation in the Consolidated WIL Help file to get some ideas.  If you do find something useful please share it as it may be useful to someone else.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


neshelman

  • Newbie
  • *
  • Posts: 2
Re: adding a printer by IP
« Reply #2 on: October 25, 2018, 09:06:38 am »
Hi, Yes, I'm looking to do this with winbatch. I want to connect directly to the network card of the printer.  We're doing this because in Windows Server 2016 you can no longer have clustered print servers and we don't want a single point of failure in a single print server.

td

  • Tech Support
  • *****
  • Posts: 2618
    • WinBatch
Re: adding a printer by IP
« Reply #3 on: October 25, 2018, 10:29:58 am »
The printui.dll is still around in Windows 10 so you might find some useful functionality in it.

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Printing~Information+PRINTUI~Docs.txt
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


td

  • Tech Support
  • *****
  • Posts: 2618
    • WinBatch
Re: adding a printer by IP
« Reply #4 on: October 26, 2018, 07:24:00 am »
Haven't tried it but here is WMI example written in VB.  It should convert it to WinBatch with little effort:

https://gallery.technet.microsoft.com/scriptcenter/41a4c996-b7f7-4d58-808d-2acac20ddbf7

The lengthy documentation fro the WMI Win32_Printer class:

https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/win32-printer
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


morenos1

  • Jr. Member
  • **
  • Posts: 66
Re: adding a printer by IP
« Reply #5 on: October 26, 2018, 07:46:59 am »
This works for me:

;-Add IP port
objWMIService = GetObject("winmgmts:")
objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
; Use IP of Printer or Machine sharing printer
objNewPort.Name = "IP_192.168.1.39"
objNewPort.Protocol = 1
objNewPort.HostAddress = "192.168.1.39"
; Enter Port number you would like to use
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = @FALSE
objNewPort.Put_

;Add printer

RunWait("rundll32.exe", 'printui.dll PrintUIEntry /if /b "Printer Name" /f "hpc4x50c.inf" /r "IP_192.168.1.39" /m "HP LaserJet 4240 PCL 6"')