码迷,mamicode.com
首页 > Windows程序 > 详细

Microsoft Windows Scripting Self-Paced Learning Guide

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

标签:blog   http   os   io   for   ar   div   amp   

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

标签:blog   http   os   io   for   ar   div   amp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!