监视打印机状态(二)

描述

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

 

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

你可能感兴趣的:(打印)