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

Automating install of a tcp/ip printer 3

Status
Not open for further replies.

secutanudu

IS-IT--Management
Oct 6, 2004
138
US
Is there any way to automate (with scripts, a batch file or otherwise) the install of a printer on a new tcp/ip port?
 
Thanks Mr. Castner. How do I run those scripts? Do i just put them in a text file with a .vbs extension? (i dont know much about scripting, obviously...) I tried that with the add printer port script, and i got an error...

I think you sent me this link in a post i made last week - sorry for the repeat.
 
My apologies, as it is not intuitive as to how to use a script file.

. Yes, the file is saved with a .VBS extention
. a logon script file or other CMD window file should natively know how to handle a script file
. or, you can make it unambigous:
cscript filename.vbs

You can in a CMD box type:

cscript //?
or wscript /?
for online help.

In addition, Microsoft has done just a great job to make scripting understandable to mere mortals:
 
Thanks - just one more thing (for now) - the first script i tried was to add a tcp/ip port. Shouldn't the script work as is (even though that IP address is invalid in our network)?

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_169.254.110.14"
objNewPort.Protocol = 1
objNewPort.HostAddress = "169.254.110.14"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_
 
It seems like that script i just posted is incomplete, as if it were cut off...
 
Ok - I tried the following script (same as the one above with a few modifications). It does add the tcp/ip port for me, but when i add a printer to that port, all of my print jobs fail. Any ideas?

Thanks,
Andrew



Set WSHNetwork = WScript.CreateObject("WScript.Network")
set shell = WScript.CreateObject( "WScript.Shell" )
CompName = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Set objWMIService = GetObject("winmgmts:\\" & CompName & "\root\cimv2")
Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "IP_150.142.153.200"
objNewPort.Protocol = 1
objNewPort.HostAddress = "150.142.153.200"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_

 
objNewPort.PortNumber = "9999"
remove this entry
 
Excellent - thanks a lot, it works. Now i gotta figure out how to write a script to install the drivers. You may be hearing from me soon :)
 
Ok I looked at what MS has on their site (which I will paste below). Where do you actually point it to the proper drivers to use? I see that example creating the "Apple LaserWriter 8500" printer. Where is it pulling the drivers? From the windows driver database? What if the printer i want to install does not have a driver built into windows (the ones I want to install are not in the driver database)?

Thanks.





strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objDriver = objWMIService.Get("Win32_PrinterDriver")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

objDriver.Name = "Apple LaserWriter 8500"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
errResult = objDriver.AddPrinterDriver(objDriver)
 
Oh also - how do i get it to install to a pre-existing tcp/ip port?

I think i need to invest in a book on VBScript.
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = "DRIVERNAME"
objPrinter.PortName = "IP_IPADDRESS"
objPrinter.DeviceID = "PRINTERNAME"
objPrinter.Location = "PRINTERLOCATION"
objPrinter.Network = True
objPrinter.Shared = False
objPrinter.ShareName = ""
objPrinter.Put_

The value of objPrinter.DriverName must be the exact name listed in the driver list. Any difference will cause the script to fail.
 
Great - what if i want to install a printer that's not in the windows driver list? Say i have the drivers out on a network drive?
 
Awesome, thanks. This is going to save us hours of work.

One more thing - is there any way to automatically set options once the printer is installed? (ie. whether there is a duplexer installed, etc?)
 
To install a printer driver not included in the native XP install:


What exactly is this doing? Will this add a printer to the list of available printers? I tried it, and don't see it available in the list. How do i assign a printer driver not included inthe native XP install to a TCP/IP port?
 
This is what I am trying to run. This runs without error, but does nothing (that i can see). It doesnt add any printer, nor does it add any printer to the list of available printers.

I outputted a msgBox with the value of intResult, and got 87. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top