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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Local Printer Ports and Printers using VBScript 1

Status
Not open for further replies.

kleinicus

MIS
Dec 4, 2002
98
US
I have a VBScript that is supposed to create a local TCP/IP printer port and then create a printer on that port. Here is my script...

Code:
strComputer = "localhost"
INFSource = "C:\Drivers\IBM\Printers\Drivers\Print\Win_2KXP\GNUD0640.inf"
DriverType = "IBM Infoprint 1000 Series"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set WSHShell = CreateObject("WScript.Shell")
Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "Port_Q990XPFP10"
objNewPort.Protocol = 1
objNewPort.HostAddress = "10.1.0.10"
objNewPort.PortNumber = "9100"
objNewPort.Put _
WSHShell.run "rundll32 printui.dll,PrintUIEntry /if /b Q990XPFP10 /f INFSource /r Port_Q990XPFP10 /m DriverType"

When I run this file, I get an error message on the script saying "Expected end of statement" in line 13 char 14. Can anyone help me get my script working?
Many thanks.

SK
 
is it the white space in here "objNewPort.Put _"

how about objNewPort.Put_
 
When I change that, I get an error message from the "Printers" subsystem saying "The operation cannot be completed"

Any other suggestions?
 
What line exactly generates this error?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
>objNewPort.Put _
>WSHShell.run "rundll32 printui.dll,PrintUIEntry /if /b Q990XPFP10 /f INFSource /r Port_Q990XPFP10 /m DriverType"
[tt]
objNewPort.Pu[highlight]t_[/highlight]
WSHShell.run "rundll32 printui.dll,PrintUIEntry /if /b Q990XPFP10 /f [red]""" & INFSource & """[/red] /r Port_Q990XPFP10 /m [red]""" & DriverType & """"[/red]
[/tt]
note: INFSource there, in priniciple, does not need to be enclosed by quotes with what it is defined. Quotes are included just in case the path is to be changed to more general path with whitespaces inside.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top