![]() ![]() Just another one of the little eccentricities we’ve come to love about WMI: any time you use a \ in a Where clause you must preface it with a second slash. Consequently we need to use this as the DeviceID: \\\\atl-ps-01\\color-printer Note that because we are using the DeviceID as part of a Where clause ( Where DeviceID =) we need to “escape” each \ in the printer path. Wscript.Echo “The test page could not be printed.”Īll we do in this script is connect to the WMI service, then run a query that binds us to the printer with the DeviceID \\atl-ps-01\color-printer. Wscript.Echo “The test page was printed successfully.” (“Select * from Win32_Printer Where DeviceID = ‘\\\\atl-ps-01\\color-printer'”) Set colPrinters = objWMIService.ExecQuery _ Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”) Here’s a sample script that does just that: strComputer = “.” As you might expect, this means you can bind to a given printer on a computer and then call the PrintTestPage method to, well, print a test page. As long as you’re running Windows XP this is an easy one that’s because the revised Win32_Printer class introduced in Windows XP includes a method called PrintTestPage. ![]() Hey, Scripting Guy! How can I print a test page to a printer?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |