Microsoft Windows Scripting Self-Paced Learning Guide

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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

 

posted @   ®Geovin Du Dream Park™  阅读(290)  评论(0编辑  收藏  举报
编辑推荐:
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
阅读排行:
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· DeepSeek 解答了困扰我五年的技术问题。时代确实变了!
· 本地部署DeepSeek后,没有好看的交互界面怎么行!
· 趁着过年的时候手搓了一个低代码框架
· 推荐一个DeepSeek 大模型的免费 API 项目!兼容OpenAI接口!
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示