首页 > Windows开发 > 详细

Microsoft Windows Scripting Self-Paced Learning Guide

时间:2014-08-13 00:56:24      阅读:353      评论:0      收藏:0      [点我收藏+]

http://www.mums.ac.ir/shares/hit/eduhit/book/windowsscripting.pdf
http://support.microsoft.com/kb/926352/en-us
https://www.microsoft.com/learning/en-us/book.aspx?id=6789
FilterPrinterStatus.vbs

Option Explicit
‘On Error Resume Next
Dim strComputer
Dim wmiNS
Dim wmiQuery
Dim objWMIService
Dim colItems
Dim objItem
Dim strStatus
strComputer = "."
wmiNS = "\root\cimv2"
wmiQuery = "Select * from Win32_Printer" _
& " Where PrinterStatus = 1" _
& " or PrinterStatus = 2" _
& " or PrinterStatus = 7"
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & wmiNS)
Set colItems = objWMIService.ExecQuery(wmiQuery)
If colItems.Count = 0 Then
WScript.Echo "all printers are fine"
Else
For Each objItem In colItems
WScript.Echo "Name: " & objItem.Name
WScript.Echo "Location: " & objItem.Location
subEvalStatus
WScript.Echo "Printer Status: " & strStatus
WScript.Echo "Server Name: " & objItem.ServerName
WScript.Echo "Share Name: " & objItem.ShareName
WScript.Echo
Next
End If
Sub subEvalStatus
Select Case objItem.PrinterStatus
Case 1
strStatus = "Other"
Case 2
strStatus = "Unknown"
Case 3
strStatus = "Idle"
Case 4
strStatus = "Printing"
Case 5
strStatus = "Warmup"
Case 6
strStatus = "Stopped Printing"
Case 7
strStatus = "Offline"
End Select
End Sub

 

Microsoft Windows Scripting Self-Paced Learning Guide,布布扣,bubuko.com

Microsoft Windows Scripting Self-Paced Learning Guide

原文:http://www.cnblogs.com/geovindu/p/3908977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!