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

Install TCP / IP printer in a domain with script

Status
Not open for further replies.

Flow8002

Programmer
Mar 30, 2011
2
FR
hi ,

I have some trouble with script .
i don't understand where the problem is ....
if some one could help me , it will be awesome !.

strComputer = "PC_01"
'strDomain = "Workgroup"

strUser = "Workgroup\Administrator"
strPassword = "toto"

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strUser, strPassword)
Set objNewPort = objSWbemServices.Get("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_192.168.0.1"
objNewPort.Protocol = 1
objNewPort.HostAddress = "192.168.0.1"
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_



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

objDriver.Name = "RICOH Aficio MP 2000 PCL 6"
'objDriver.FilePath = "\\Server01\D$\ricoh\disk1"
'objDriver.Infname = "\\Server01\D$\ricoh\disk1\OEMSETUP.INF"
objDriver.FilePath = "C:\ricoh0\disk1\"
objDriver.Infname = "C:\ricoh0\disk1\OEMSETUP.INF"
intResult = objDriver.AddPrinterDriver(objDriver)


Set objPrinter = objSWbemServices.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "RICOH Aficio MP 2000 PCL 6"
objPrinter.PortName = "IP_192.168.0.1"
objPrinter.DeviceID = "RICOH Aficio MP 2000 (192.168.0.1)"
objPrinter.Location = ""
objPrinter.Network = True
objPrinter.Shared = False
objPrinter.Put_



When i put the driver file on the remote machine "C:/" it's work fine , but when the driver file are on the server the result of my code is an error 87 .

Thank's for your Help .
 
According to error 87 means "invalid parameter". It was suggested that drive files MUST be on the remote machine. They cannot be pulled from the server.

You can get around this by first copying the files to the remote machine first.

Although, ideally, you should create the printer on a server and share it out. Installing a shared domain printer is as simple as
Code:
objShell.Network = WScript.CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection "\\server\printer_name"

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Thanks for your answer & your help .
Unfortunately i can't Install a shared domain printer because the structure of my enterprise don't permit it ... :/

I will be to try the first possibility copying the file driver to remote machine but i'm affraid about the time of download driver file ...

I'm very susprise that no solution exist to get driver file on the remote server .
After 3 weeks of research on the web , i started to believe :).

 
Yeah, if any of the printers are HP, you might have issues copying the 100mb of USELESS DRIVER information, when all you need is a couple KBs.

Actually, the universal printer driver from HP is small and works well for BASIC functionality of other printer manufacturers.

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top