title: Add local Printer port with VBS
body: <p>first of all i'm sorry for my english.</p>
  
  <p>I've one question about windows WMI and how to add a local port to shared printer. I've this script:</p>
  
  <pre><code>Set objWMIService = GetObject("winmgmts:")
  Set objNewPort = objWMIService.Get _
  ("Win32_TCPIPPrinterPort").SpawnInstance_
  objNewPort.Name = "Ricoh3300C"
  objNewPort.Protocol = 2
  objNewPort.HostAddress = "XXX.XXX.X.XXX"
  objNewPort.PortNumber = "9100"
  objNewPort.SNMPEnabled = False
  objNewPort.Put_
  </code></pre>
  
  <p>With this i can add a printer with IP address but i want to add a printer in samba server with an address like "\\XXX.XXX.X.XXX\printerColor". I've lost a lot of time in google trying to find an script and all that i've seen is for TCPIP ports. I wan't to do it but in local port.</p>
  
  <p>I've tried to use this script with prnadmin.dll and no luck.</p>
  
  <pre><code>function PortAdd(strPort, portType)
  
      on error resume next
  
      dim oMaster
      dim oPort
      dim iResult
  
      set oMaster = CreateObject("PrintMaster.PrintMaster.1")
      set oPort   = CreateObject("Port.Port.1")
  
      iResult = kErrorFailure
  
      oPort.PortName = strPort
      oPort.PortType = portType
  
      oMaster.PortAdd oPort
  
      if Err = 0 then
  
          iResult = kErrorSuccess
  
      else
  
          wscript.echo "Error: 0x" &amp; Hex(Err.Number) &amp; ". " &amp; Err.Description 
  
      end if
  
      PortAdd = iResult
  
  end function
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Error: 0x1A8. Se requiere un objeto
  </code></pre>
  
  <p>in english is like</p>
  
  <pre><code>Error: 0x1A8. An object is required
  </code></pre>
  
  <p>How can i fix that error or what script can i use to add a local port?. Thanks in advance.</p>
  
  <p>I forgot to say that i want to do it with normal user without admin access. The first script works fine in that users but is for TCPIP.</p>