Jump to content

Test whether default printer can print?


Recommended Posts

This is a question about a script that will run on Windows 2000, XP, and above (I hope) only. I want to be able to test whether the Windows default printer is actually working or not by printing a test page (even a single word is enough) so that the user can see if the printer is actually functioning.

I know how to use RegRead to determine the current default printer (in fact, this is already in my script). As far as I can tell, the print dialog in Notepad always selects shows the default printer (other applications may show the most-recently used printer instead). But it seems to me more reliable to be able to access the driver for the default printer and use the "print test page" feature instead.

Does anyone know a way to script the "print test page" item for the default printer??

Thanks for any help.

Link to comment
Share on other sites

See _FilePrint in the Beta helpfile.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

  • Developers

Try:

$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(LoadDriver)}!\\" & @ComputerName & "\root\cimv2")
$colInstalledPrinters =  $objWMIService.ExecQuery ("Select * from Win32_Printer Where Default = True")
For $objPrinter in $colInstalledPrinters
    $uResult = $objPrinter.PrintTestPage()  
Next

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Try:

$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate,(LoadDriver)}!\\" & @ComputerName & "\root\cimv2")
$colInstalledPrinters =  $objWMIService.ExecQuery ("Select * from Win32_Printer Where Default = True")
For $objPrinter in $colInstalledPrinters
    $uResult = $objPrinter.PrintTestPage()  
Next
Absolutely one-hundred-percent perfect. Also elegant.

Thank you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...