首页 > 代码库 > Microsoft Windows Scripting Self-Paced Learning Guide
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
Option Explicit‘On Error Resume NextDim strComputerDim wmiNSDim wmiQueryDim objWMIServiceDim colItemsDim objItemDim strStatusstrComputer = "."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 ThenWScript.Echo "all printers are fine"ElseFor Each objItem In colItemsWScript.Echo "Name: " & objItem.NameWScript.Echo "Location: " & objItem.LocationsubEvalStatusWScript.Echo "Printer Status: " & strStatusWScript.Echo "Server Name: " & objItem.ServerNameWScript.Echo "Share Name: " & objItem.ShareNameWScript.EchoNextEnd IfSub subEvalStatusSelect Case objItem.PrinterStatusCase 1strStatus = "Other"Case 2strStatus = "Unknown"Case 3strStatus = "Idle"Case 4strStatus = "Printing"Case 5strStatus = "Warmup"Case 6strStatus = "Stopped Printing"Case 7strStatus = "Offline"End SelectEnd Sub
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。