Hi all and sorry for my broken English)
Ihave a problem with install local printer from vbs (I plan torun it as user logon-script) on Win7without
administrator rights.I tried different methods (rundll32 printui.dll,PrintUIEntry /Printing_Admin_Scripts
in Win7 / standard scriptbelow). Now we use AD + printserver
with shared printers and network printers connected to users based on room by logon-script (thinkit is the standard for many), but i need install local printers on 40-50 computers insteadnetwork printers.
Dim Computer, DriverName, DriverInf, IPAddress, PortName, PrinterName
Dim WMI, NewPort, NewDriver, NewPrinter
Computer = "."
DriverName = "Xerox Phaser 3435 PCL 6"
DriverInf = "D:\drivers\Xerox Phaser 3435 PCL 6\sxc2m.inf"
IPAddress = "1.2.3.4"
PrinterName = "name1"
PortName = IPAddress
Set WMI = GetObject("winmgmts:{impersonationlevel=impersonate" _ & ",(loaddriver)}!//" & Computer & "/root/cimv2")
Set NewDriver = WMI.Get("Win32_PrinterDriver")
NewDriver.Name = DriverName
NewDriver.InfName = DriverInf
Result = NewDriver.AddPrinterDriver(NewDriver)
'If Result = 0 Then
' WScript.Echo "Added printer driver: " & DriverName
'Else
' WScript.Echo "Error " & Result & " adding printer driver: " & DriverName
' WScript.Quit
'End If
Set NewPort = WMI.Get("Win32_TCPIPPrinterPort").SpawnInstance_
NewPort.HostAddress = IPAddress
NewPort.Name = IPAddress
NewPort.Protocol = 1 ' 1 = Raw, 2 = LPR
NewPort.Put_
WScript.Echo "Created printer port: " & PortName
Set NewPrinter = WMI.Get("Win32_Printer").SpawnInstance_
NewPrinter.DriverName = DriverName
NewPrinter.DeviceID = PrinterName
NewPrinter.PortName = IPAddress
NewPrinter.Put_
WScript.Echo "Created printer: " & PrinterNameSo after run script im get message: " Win32 error 5 - Access is denied" and script exit. Ok, try run script as administrator - all works. Ok, try install local printer manuallythrough "Printers and devices"with other driver - enter IP, port,...choose driver (inf-file) and printer easy install. Try this driver in script(maybe itdriver) - nothing changes. What's the difference between i try install driver from script and manuallyas a normal user,notthe administrator???
I go to GPO and disable parameters Point and Print Restrictions in Computer Configuration and User Configuration (http://technet.microsoft.com/en-us/library/cc753269.aspx), reboot and gpupdate /force my PC -nothing changes.
Ok, when network printers connected after logondrivers alsopulledfrom printserver. I go to printmanagement.msc and see that all drivers i needis already installedon my PC. In script above i delete block with install driver and after run i get error "SWbemObjectEx: Generic failure"references thestring "NewPrinter.Put_". One of the sitesI read that this error may bedue to the fact that the driver is not installed.....closed circle...
I would be gladifsomeone can help
in solving this problem, ty.