博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WMI中相关的操作说明execquery 或者是instancesof
阅读量:6915 次
发布时间:2019-06-27

本文共 4531 字,大约阅读时间需要 15 分钟。

 

原文地址:

Win32_DiskQuota - VB Script code samples

Get instance of WMI class using GetObject

Short VBS code - get a single specified instance of Win32_DiskQuota class or get a default unnamed instance (singleton) of the class, using one single command GetObject with exact path of the wmi object.

'http://wutils.com/wmi/Dim wmiObjectSet wmiObject = GetObject( _ "WINMGMTS:\\.\ROOT\cimv2:" + _ "Win32_DiskQuota.QuotaVolume=""Path to "",User=""Path to """)Wscript.Echo wmiObject.DiskSpaceUsed 'or other property name, see table bellow

Alternative codes

SWbemServices.Get

Quickest and most efficient VB Script code to get a single instance by a key - SWbemServices.Get

'http://wutils.com/wmi/Dim oWMI, Instance'Get base WMI object, "." means computer name (local)Set oWMI = GetObject("WINMGMTS:\\.\ROOT\cimv2")Do  'Get the instance of Win32_DiskQuota   Set Instance = oWMI.Get("Win32_DiskQuota.QuotaVolume=""Path to "",User=""Path to """)                      'Do something with the instance  Wscript.Echo Instance.DiskSpaceUsed 'or other property name  'Wait for some time to get next value  Wscript.Sleep 1000Loop While True
WMI query - sample windows WQL

Get a specified instance of Win32_DiskQuota by key, get a default unnamed instance (singleton) of the class or list instances of the class by wmi query using this VB Script.

'http://wutils.com/wmi/Dim oWMI, WQL, Instances, Instance'Get base WMI object, "." means computer name (local)Set oWMI = GetObject("WINMGMTS:\\.\ROOT\cimv2")'Create a WMI query text WQL = "Select * from Win32_DiskQuota"'Get instances of Win32_DiskQuota Set Instances = oWMI.ExecQuery(WQL)                    'Enumerate instances  For Each Instance In Instances   'Do something with the instance  Wscript.Echo Instance.DiskSpaceUsed 'or other property nameNext 'Instance
InstancesOf

List of all instances, wmi class Win32_DiskQuota.

'http://wutils.com/wmi/Dim oWMI, Instances, Instance'Get base WMI object, "." means computer name (local)Set oWMI = GetObject("WINMGMTS:\\.\ROOT\cimv2")'Get instances of Win32_DiskQuota Set Instances = oWMI.InstancesOf("Win32_DiskQuota")'Enumerate instances  For Each Instance In Instances   'Do something with the instance  Wscript.Echo Instance.DiskSpaceUsed 'or other property nameNext 'Instance
WMI remote scripting - Locator, Connect

Get WMI management object using method. You can connect to a remote computer and specify Username/Password for the WMI connection.

'http://wutils.com/wmi/Dim Locator, oWMI, WQL, Instances, Instance'Create Locator objectSet Locator = CreateObject("WbemScripting.SWbemLocator")'Get base WMI objectSet oWMI = Locator.ConnectServer("MachineName", "ROOT\cimv2", "MachineName\administrator", "Password") '.... continue using oWMI object

Win32_DiskQuota properties

Name

CIMType
IsArray
IsLocal
Origin
read
Units
write
key
ValueMap
Qualifiers

DiskSpaceUsed

21,uint64
NO
YES
Win32_DiskQuota
True
"Bytes"
-

Limit

21,uint64
NO
YES
Win32_DiskQuota
True
"Bytes"
True
-

key

QuotaVolume

102,ref:
NO
YES
Win32_DiskQuota
True
True
-

Status

19,uint32
NO
YES
Win32_DiskQuota
True
Array["0","1","2"]
-

key

User

102,ref:
NO
YES
Win32_DiskQuota
True
True
-

WarningLimit

21,uint64
NO
YES
Win32_DiskQuota
True
"Bytes"
True
-

Win32_DiskQuota derivation

Win32_DiskQuota is top level class. See or .

Sample of Instances (Win 2003 Server)

Number of instances: 9999, Key Names:QuotaVolume,User

Win32_DiskQuota Qualifiers

Name

Value
ToInstance
ToSubclass
Overridable
Amended
Local

Association

True
YES
YES
NO
NO
YES

CreateBy

"PutInstance"
NO
NO
YES
NO
YES

DeleteBy

"DeleteInstance"
NO
NO
YES
NO
YES

dynamic

True
YES
NO
YES
NO
YES

Locale

&1033
YES
NO
YES
NO
YES

provider

"DskQuotaProvider"
YES
NO
YES
NO
YES

SupportsCreate

True
NO
NO
YES
NO
YES

SupportsDelete

True
NO
NO
YES
NO
YES

SupportsUpdate

True
NO
NO
YES
NO
YES

UUID

"B94560CA-41CC-4FB5-BD56-282329DA41DA"
YES
NO
YES
NO
YES

Win32_DiskQuota System properties

Name

Value
Origin
CimType
Local
Array

__PATH

"\\TRIPLE\ROOT\cimv2:Win32_DiskQuota"
___SYSTEM
8
False
False

__NAMESPACE

"ROOT\cimv2"
___SYSTEM
8
False
False

__SERVER

"TRIPLE"
___SYSTEM
8
False
False

__DERIVATION

Array[]
___SYSTEM
8
False
True

__PROPERTY_COUNT

&6
___SYSTEM
3
False
False

__RELPATH

"Win32_DiskQuota"
___SYSTEM
8
False
False

__DYNASTY

"Win32_DiskQuota"
___SYSTEM
8
False
False

__SUPERCLASS

___SYSTEM
8
False
False

__CLASS

"Win32_DiskQuota"
___SYSTEM
8
False
False

__GENUS

&1
___SYSTEM
3
False
False

- WMI reference for windows server. Quick VBScript and c# code samples.

转载于:https://www.cnblogs.com/alterhu/archive/2012/04/09/2439064.html

你可能感兴趣的文章
spring+mybatis 多数据源整合
查看>>
HTML5 网络拓扑图整合 OpenLayers 实现 GIS 地图应用
查看>>
php 两种短网址生成方法
查看>>
AOP - PostSharp 2.0
查看>>
Spring测试框架JUnit4.4
查看>>
openSUSE 12.1下搭建Web服务器
查看>>
Contact Manager Web API 示例[2] Web API Routing
查看>>
用luasocket读取双色球中奖号码
查看>>
C#中ref和out的使用小结
查看>>
Extjs4 中的gird
查看>>
错排-HDU 2049 递推的应用
查看>>
参数化查询为什么能够防止SQL注入
查看>>
AlertDialog.Builder弹出对话框
查看>>
HDUOJ -----1686
查看>>
pomelo组件..
查看>>
[问题2014S03] 解答
查看>>
mybatis入门例子
查看>>
[LeetCode] Construct Binary Tree from Inorder and Postorder Traversal
查看>>
Sencha touch 初体验
查看>>
锋利的jQuery-1--解决jquery库和其他库的冲突
查看>>