/build/static/layout/Breadcrumb_cap_w.png

Installing printing using Kbox and VBScript

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 

Else 

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

  WScript.Quit 

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 

NewPort.Put_ 

 

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 

NewPrinter.Put_ 

 

WScript.Echo "Created printer: " & PrinterName 


0 Comments   [ + ] Show comments

Answers (2)

Answer Summary:
Posted by: dugullett 12 years ago
Red Belt
2

http://www.itninja.com/question/kace-k1000-how-do-you-run-a-vbscript-file

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

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ