Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PRNADMIN.DLL Servername error

Status
Not open for further replies.

goddersb

Programmer
Mar 26, 2009
14
GB
I am trying to create a printer mapping application using the prnadmin.dll, i am getting the error "The parameter is incorrect" when i try to set the parameter" ServerName. I have tried IP address, Logical name etc. But i am unable to get past this issue. If i leave this blank it is creating the port successfully, but if i state the remote machine for which i wish to create the port and then map the printer i can get no further.
 
'First Define the Port
Try
oPort = CreateObject("Port.Port.1")
oMaster = CreateObject("PrintMaster.PrintMaster.1")
WshShell = CreateObject("WScript.Shell")

'Edit for computer name
mstrMachineName = "\\" & Me.DEVICE_NAME

'Edit for IP port name
mstrPortName = "_" & Me.PRINTER_IP_ADDRESS

'Edit for IP address
mstrIPAdress = Me.PRINTER_IP_ADDRESS

'Indicate where to add the port. Double quotes ("") stand for the local computer, which is the default.
oPort.ServerName = "\\34.101.120.8"

'The name of the port cannot be omitted.
oPort.PortName = "LTP99"

'The type of the port can be 1 (TCP RAW), 2 (TCP LPR), or 3 (standard local).
oPort.PortType = 1

'Mandatory for TCP ports. This is the address of the device to which the port connects.
oPort.HostAddress = PRINTER_NAME

'For TCP RAW ports. Default is 9100.
oPort.PortNumber = 9100

'Enable or disable SNMP.
oPort.SNMP = False

'Applies to TCP LPR name, default is LPR
oPort.QueueName = "Queue"

'Byte counting or double spool applies to TCP LPR ports, is disabled by default.
oPort.DoubleSpool = False

'Try adding the port.
oMaster.PortAdd(oPort)

MessageBox.Show("IP Port Add Successful", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information)

Catch ex As Exception
MessageBox.Show(ex.Message, "Error Mapping Printer", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)
End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top