I have a script that I have been using to install a network printer from command line. The dell kace pushes it out to the workstation, but I have been unable to get it to execute the script. Can anyone show me a link to how to sucessfully run a vbscript from the dell kace? Here is the code:

Dim Computer, DriverName, DriverInf, IPAddress, PortName, PrinterName 

Dim WMI, NewPort, NewDriver, NewPrinter 


' Enter Details of Printer 

' Computer on which to create the printer. 

Computer = "." 

' The printer driver's name. 

DriverName = "Canon iR-ADV C7055/7065 UFR II" 

' The full path and filename of the .inf file. 

DriverInf = "\\Path\to\INF\CNLB0U.inf" 

' The printer's IP address. 

IPAddress = "ip.of.network.printer" 

' The printer's Name. 

PrinterName = "ADV C7065" 

' End of Details entering 


' The port name that will be created. 

PortName = "IP_" & IPAddress 


' Establish WMI connection to specified computer. 

' Note that the loaddriver privilege is required to add the driver. 

Set WMI = GetObject("winmgmts:{impersonationlevel=impersonate" _ 

  & ",(loaddriver)}!//" & Computer & "/root/cimv2") 


' Step A: Install the printer's driver. 

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 


  WScript.Echo "Error " & Result & " adding printer driver: " & DriverName 


End If 


' Step B: Create a TCP/IP printer port for the printer. 

Set NewPort = WMI.Get("Win32_TCPIPPrinterPort").SpawnInstance_ 

NewPort.HostAddress = IPAddress 

NewPort.Name = PortName 

NewPort.Protocol = 1  ' 1 = Raw, 2 = LPR 



WScript.Echo "Created printer port: " & PortName 


' Step C: Add the printer. 

Set NewPrinter = WMI.Get("Win32_Printer").SpawnInstance_ 

NewPrinter.DriverName = DriverName 

NewPrinter.DeviceID = PrinterName 

NewPrinter.PortName = PortName 



WScript.Echo "Created printer: " & PrinterName 

Answer Summary:
0 Comments   [ - ] Hide Comments


Please log in to comment

Community Chosen Answer




Also with printers make sure you change to "logged in user" since by default it will run as SYSTEM.

Answered 07/27/2012 by: dugullett
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity


Answered 07/27/2012 by: SMal.tmcc
Red Belt

Please log in to comment