导航

监视打印机状态(二)

Posted on 2008-03-25 10:48  pegger  阅读(455)  评论(0编辑  收藏  举报

描述

显示计算机上所有打印机的当前状态。

 

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    (
"Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
    Wscript.Echo  
"Name: " & objPrinter.Name
    Wscript.Echo  
"Location: " & objPrinter.Location
    
Select Case objPrinter.PrinterStatus
        
Case 1
            strPrinterStatus 
= "Other"
        
Case 2
            strPrinterStatus 
= "Unknown"
        
Case 3
            strPrinterStatus 
= "Idle"
        
Case 4
            strPrinterStatus 
= "Printing"
        
Case 5
            strPrinterStatus 
= "Warmup"
    
End Select
    Wscript.Echo  
"Printer Status: " & strPrinterStatus
    Wscript.Echo  
"Server Name: " & objPrinter.ServerName
    Wscript.Echo  
"Share Name: " & objPrinter.ShareName
    Wscript.Echo
Next
河南恒友科贸有限公司 
电话 :0371-53733453    传真:0371-65388972
地址:郑州市郑花路8号 E-mail:hengyousoft@QQ.com