WMI for printer page count


W

wiwa

Hi,

I would like to write a program that gets the printer page count from
several network printers (all connected to 1 print server). I think WMI is
suited for that purpose but I don't know exactly how to start. Anyone who
can help with some sample code or pointers to usefull websites.

Thanks,

WiWa
 
Ad

Advertisements

P

Philip Nunn [MSFT]

Here's a script to get you started. Below is also some links for further
information.


const wbemFlagReturnImmediately = &h10
const wbemFlagForwardOnly = &h20

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PrintJob",
"WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)

for each objItem In colItems
wscript.echo "Print Job:" & vbTab & objItem.Name
wscript.echo "Total Pages:" & vbTab & objItem.TotalPages
wscript.echo "PagesPrinted:" & vbTab & objItem.PagesPrinted
wscript.echo
next



WMI capabilities also include eventing, remoting, querying, views, user
extensions to schema, instrumentation, and more.

To learn more about WMI, go to http://msdn.microsoft.com/library/default.asp
and search for the keyword phrase "About WMI"


The Microsoft Developers Network (MSDN) and TechNet are both good sources of
samples. Here are some links to useful locations on these sites:

. The TechNet Script Center
Includes hundreds of sample scripts categorized by technology and
administrative task.
http://go.microsoft.com/fwlink/?LinkId=24771.

. MSDN
http://msdn.microsoft.com/library.
For WMI scripts, search for "WMI System Administration scripts".
For WMIC (the WMI Command Line Utility), see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmic.asp .

. The WMI Software Developers Kit (SDK)

http://www.microsoft.com/msdownload/platformsdk/sdkupdate
For a set of problem solutions by category, see Using WMI > WMI Tasks
for Scripts and Applications.

. The Windows 2000 Scripting Guide online
The complete text of the book, which includes many examples of WMI
scripting.
http://www.microsoft.com/resources/documentation/windows/2000/server/scriptguide/en-us/default.mspx

. The "Tales from the Script" column on TechNet
Basic and intermediate scripting topics.
http://www.microsoft.com/technet/community/columns/scripts/default.mspx

. The "Scripting Clinic" column on MSDN
More advanced scripting topics.
http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28001169

. Newsgroups
You can post questions about WMI and WMI applications or scripts to
several newsgroups on the Msnews.microsoft.com news server:
Microsoft.public.win32.programmer.wmi

Microsoft.public.windowsxp.wmi

Microsoft.public.windows.server.scripting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

WMI to change printer options 0
WMI to detect printer online/offline 1
WMI 0
Wmi 0
Wmi 0
Run WMI within WMI 0
wmi issue 0
WMI Error 14

Top