Jump to content
Sign in to follow this  
emendelson

Test whether default printer can print?

Recommended Posts

emendelson

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.

Share this post


Link to post
Share on other sites
BigDod

See _FilePrint in the Beta helpfile.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
emendelson

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!

Share this post


Link to post
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
Sign in to follow this  

×