Currently I am using the following to install a printer and print a test page.

I start the procedure with install.bat which moves the driver files, installation script and print test page script to a temp directory, calls the installation, resets the print spooler and then calls for a test page to be printed.


::copy driver files and scripts to temp directory
robocopy PrintInstall %temp%\PrintInstall *.* /E
::install printer driver
call "%temp%\PrintInstall\PrintInstall.vbs
::restart print spooler service
net stop spooler && net start spooler
::print test page
call "%temp%\PrintInstall\printTestPage.vbs
::cleanup installation files
rmdir "%temp%\PrintInstall" /S /Y


strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objNewPort = objWMIService.get("Win32_TCPIPPrinterPort").SpawnInstance_
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
Set objDriver = objWMIService.Get("Win32_PrinterDriver")
objDriver.Name = "Kyocera TASKalfa 420i" 'Driver name in INF file
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.FilePath = "C:\\PrintInstall\\Driver\\" 'Path to inf file
objDriver.Infname = "C:\\PrintInstall\\Driver\\OEMSETUP.INF" 'Path and name if inf file
intResult = objDriver.AddPrinterDriver(objDriver)

'Installs Printer Port
objNewPort.Name = "" 'change to the port address or name
objNewPort.Protocol = 1
objNewPort.HostAddress = "" 'change to the port address or name
objNewPort.PortNumber = 9100 'Change to appropriate port number if needed
objNewPort.SNMPEnabled = True

'Install Printer
objPrinter.DriverName = "Kyocera TASKalfa 420i" 'change to match the driver name in the INF same as first line above
objPrinter.PortName = "" 'change to the port address or name
objPrinter.DeviceID = "Marietta - Kyocera TaskAlfa 420i KX" 'Friendly name displayed in control panel
objPrinter.Location = ""
objPrinter.Default = 1
objPrinter.Network = True


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where DeviceID = 'Marietta - Kyocera TaskAlfa 420i KX'")
For Each objPrinter in colPrinters
errReturn = objPrinter.PrintTestPage
If errReturn = 0 Then
Wscript.Echo "The test page was printed successfully."
Wscript.Echo "The test page could not be printed."
End If

I eventually want to move this all into one script, and will hopefully get a chance to work on that soon and bug you guys, but my main question has to do with the Printing of the Test Page. This script works perfectly on every Canon and HP printer I have used it for so far. However, when I try to install a Kyocera, such as the one in the example above I get the else pop-up of "The test page could not be printed." The printer installs perfectly, and I can print a test page from the properties of the printer.

Does anyone know of a different method to attempt calling for a test page to print?
0 Comments   [ + ] Show Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.


Try using Prnqctl.vbs, should be located in "System32\Printing_Admin_Scripts".
Answered 02/23/2011 by: package_aligator
Orange Belt

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