1.《WMI技术指南》:这个是基本上已经绝版的好图书,在网上唯一能找到的是来自“MS技术中国”的扫描版,该书我也是向该论坛斑竹索取的。谢谢技术中国也谢谢CN-DOS。
下载地址: http://zhenlove.com.cn/cndos/fileup/files/Wmi技术指南(PDF).rar
2.《WMI开发文档》来自MS网站,下载地址是:http://zhenlove.com.cn/cndos/fileup/files/wmisdk(WMI开发文档).rar
3.《WMIC:从命令行对Windows的全面管理》,收集于网站:下载地址: http://zhenlove.com.cn/cndos/fileup/files/WMIC从命令行对Windows的全面管理.rar
4.一段关于WMI的脚本,该脚本来自MS网站,原内容有点问题,稍微修正了一下.要运行该脚本,请复制代码到记事本中并保存为"search.vbs",注意保存时必须加引号,否则不是脚本文件而是文本文件;然后到CMD下使用命令,格式如下:Search.vbs 类关键字,该脚本可以实现搜索WMI CLASS的是属性等.
;代码开始=============================================
Set args = wscript.arguments
If args.Count <= 0 Then
Wscript.Echo "Tool to search for a matching class in the WMI Repository. "
Wscript.Echo "USAGE: <keywordToSearch> [<namespaceToSearchIn>]"
Wscript.Echo "Example1: Cscript search.vbs service"
Wscript.Echo "Example2: Cscript search.vbs video root\cimv2"
Else
' If no Namespace is specified then the Default is the ROOT namespace
rootNamespace = "\\.\ROOT"
keyword = args(0)
If args.Count > 1 Then
rootNamespace = args(1)
End If
EnumNameSpace rootNamespace
Wscript.Echo vbNewLine
End if
' Subroutine to recurse through the namespaces
Sub EnumNameSpace(parentNamespaceName)
Set objService = GetObject("winmgmts:" & parentNamespaceName)
Set collMatchingClasses = objService.Execquery _
("Select * From meta_class Where __class " & _
"Like '%" & keyword & "%'")
If (collMatchingClasses.count > 0) Then
Wscript.Echo vbNewLine
Wscript.Echo vbNewLine
Wscript.Echo "Matching Classes Under Namespace: " & parentNamespaceName
For Each matchingClass in collMatchingClasses
Wscript.Echo " " & matchingClass.Path_.CLASS
Next
End if
Set collSubNamespaces = objService.Execquery _
("select * from __namespace")
For Each subNameSpace in collSubNamespaces
EnumNameSpace subNameSpace.path_.namespace + _
"\" + subNameSpace.Name
Next
End Sub
;代码结束======================================================
5.WMI CLASSES有关资料,来源于MS网站,下载地址:http://zhenlove.com.cn/cndos/fileup/files/WMI Classes.rar
关于检查电脑所有脚本版本检测的有关脚本,请把代码保存为version.vbs.双击运行或在CMD下输入 start version.vbs (注意匹配自己的路径)
;代码开始===============================================
On Error Resume Next
WScript.Echo "WSH Version: " & WScript.Version
Wscript.Echo "VBScript Version: " & ScriptEngineMajorVersion _
& "." & ScriptEngineMinorVersion
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\cimv2")
Set colWMISettings = objWMIService.ExecQuery _
("Select * from Win32_WMISetting")
For Each objWMISetting in colWMISettings
Wscript.Echo "WMI Version: " & objWMISetting.BuildVersion
Next
Set objShell = CreateObject("WScript.Shell")
strAdsiVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\Version")
If strAdsiVersion = vbEmpty Then
strAdsiVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\ADs\Providers\LDAP\")
If strAdsiVersion = vbEmpty Then
strAdsiVersion = "ADSI is not installed."
Else
strAdsiVersion = "2.0"
End If
End If
WScript.Echo "ADSI Version: " & strAdsiVersion
;代码结束==========================================
.再来传一个WMI的有关工具,这个还是从MS网站上搞下来的.MS把这个东西吹的很好哟.这个实际上是一个HTML文件.我把代码贴上来,请复制所有代码到文本文件中,然后保存为"scriptomatic.hta"双击运行即可.
;代码开始====================================
<html>
<!--********************************************************************
'*
'* File: scriptomatic.hta
'* Created: August 2002
'* Version: 1.0
'*
'* Description: Learning tool. Enables users to generate and run
'* WSH scripts (in VBScript) that use WMI to display
'* properties available through the Win32_ classes.
'*
'*
'* Copyright (C) 2002 Microsoft Corporation
'*
'********************************************************************-->
<title>Windows .NET Server Resource Kit - Scriptomatic</title>
'*********************************************
'* WHILE LOADING...
'*
'* As the application loads, we open a new
'* browser window to act as a crude progress dialog
'* while we wait for the enumeration of the WMI
'* classes to complete.
'*
'* We minimize the parent window prior to presenting
'* the progress dialog and resize it back to normal
'* once the classes are enumerated.
'*
'*********************************************
'****************************************************************************
'* enumerate the WMI classes in the cimv2 namespace, filling up a recordset
'* with the names of the classes that begin with Win32_ and are not association
'* classes. we'll use the class names stored in the recordset to populate a
'* pulldown.
'*****************************************************************************
Set rsDataList = CreateObject("ADODB.Recordset")
rsDataList.Fields.Append "ClassName", adVarChar, MaxCharacters
rsDataList.Open
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
iCounter = 0
For Each objclass in objWMIService.SubclassesOf()
'* write a . to the dialog window once for every 250 classes
'* to let the user know something is still happening.
iCounter = iCounter + 1
If iCounter Mod 250 = 0 Then
objDialogWindow.document.writeln "."
End If
bIsQualifier = False
If UCase(Left(objClass.Path_.Class,5)) = "WIN32" Then
For Each Qualifier in objClass.Qualifiers_
If UCase(Trim(Qualifier.Name)) = "ASSOCIATION" Then
bIsQualifier = True
End If
Next
'* the class name starts with win32_ and is not an association
'* class - so append it to the recordset
If bIsQualifier = False Then
rsDataList.AddNew
rsDataList("ClassName") = objClass.Path_.Class
rsDataList.Update
End If
End If
Next
'* the user hasn't had a chance to select a class and generate
'* a script - so disable the run and save buttons because
'* they are not yet meaningful.
'****************************************************************************
'* when the user selects a class from the pulldown, the ComposeCode subroutine
'* is called. it queries WMI to determine the properties of the class the user
'* selected and uses the information to construct sample code which it puts
'* in the main window's textarea.
'****************************************************************************
Sub ComposeCode
'* if the user happens to select the message instead of a class, just
'* disable the run and save buttons and exit the subroutine
If ClassesPulldown.Value = "PulldownMessage" Then
run_button.disabled = True
save_button.disabled = True
Exit Sub
End If
'****************************************************************************
'* when the user presses the Run button, we use the WshShell object's Run
'* method to run the code currently in the textarea under cscript.exe. we use
'* cmd.exe's /k parameter to ensure the command window remains visible after
'* the script has finished running.
'****************************************************************************
Sub RunScript
Set objFS = CreateObject("Scripting.FileSystemObject")
strTmpName = "temp_script.vbs"
Set objScript = objFS.CreateTextFile(strTmpName)
objScript.Write code.InnerText
objScript.Close
Set objShell = CreateObject("WScript.Shell")
strCmdLine = "cmd /k cscript.exe "
strCmdLine = strCmdLine & strTmpName
objShell.Run(strCmdLine)
End Sub
'****************************************************************************
'* when the user presses the Save button, we present them with an InputBox
'* and force them to give us the full path to where they'd like to the save
'* the script that is currently in the textarea. The user is probably quite
'* upset with our laziness here....and who can blame them?
'****************************************************************************
Sub SaveScript
Set objFSO = CreateObject("Scripting.FileSystemObject")
strSaveFileName = InputBox("Please enter the complete path where you want to save your script (for example, C:\Scripts\MyScript.vbs).")
If strSaveFileName = "" Then
Exit Sub
End If
Set objFile = objFSO.CreateTextFile(strSaveFileName)
objFile.WriteLine code.InnerText
objFile.Close
End Sub
'****************************************************************************
'* when the user presses the Open button, we present them with an InputBox
'* and force them to give us the full path to the script they'd like to open.
'* This is, of course, rather wonky - but it's meant to be.
'****************************************************************************
Sub OpenScript
Set objFSO = CreateObject("Scripting.FileSystemObject")
strOpenFileName = InputBox("Please enter the complete path name for your script (for example, C:\Scripts\MyScript.vbs).")
If strOpenFileName = "" Then
Exit Sub
End If
'****************************************************************************
'* when the user presses the Quit button, the file where we've been storing
'* the scripts gets deleted and the main window closes.
'****************************************************************************
Sub QuitScript
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile "temp_script.vbs"
Set objFSO = Nothing
self.Close()
End Sub
</script>
</head>
'***********************************************************
'* our HTML layout - the only thing of note here is that when
'* each of the buttons is pressed (clicked), their onClick
'* attributes causes the appropriate subroutine to be called
'***********************************************************
发晚了一步。作者: HUNRYBECKY 时间: 2006-12-13 02:23 WMI是包含WMIC的。所以可以下载哈。作者: HUNRYBECKY 时间: 2006-12-13 02:26 3.《WMIC:从命令行对Windows的全面管理》:在补一个,这个是从网络上收集的,也不知道是从那里下载的了。
下载地址: http://zhenlove.com.cn/cndos/fileup/files/WMIC从命令行对Windows的全面管理.rar作者: HUNRYBECKY 时间: 2006-12-13 02:28 这里的上传系统好慢呀。传一个《WMI技术指南》都花了我两个小时。作者: lxmxn 时间: 2006-12-13 02:29
2楼中的链接无法下载,提示找不到资源。作者: lxmxn 时间: 2006-12-13 02:30
6楼同样的问题。作者: HUNRYBECKY 时间: 2006-12-13 02:32 2楼以下的都还在上传中,因为上传系统说了:下载地址前面不变,后面的就是文件名,所以传完后应该可以连接,如果不行,通知我修正下。作者: lxmxn 时间: 2006-12-13 02:34
晕死,还没有完全上传上去你就把地址帖出来啊?汗一个先……作者: HUNRYBECKY 时间: 2006-12-13 02:35 2楼的已经传完,连接果然是正确的。不好意思,我这里传,很慢,所以先发帖,呵呵,太难等了。作者: HUNRYBECKY 时间: 2006-12-13 02:44 4.再来一段关于WMI的脚本,该脚本来自MS网站,原内容有点问题,稍微修正了一下.要运行该脚本,请复制代码到记事本中并保存为"search.vbs",注意保存时必须加引号,否则不是脚本文件而是文本文件;然后到CMD下使用命令,格式如下:Search.vbs 类关键字,该脚本可以实现搜索WMI CLASS的是属性等.
;代码开始=============================================
Set args = wscript.arguments
If args.Count <= 0 Then
Wscript.Echo "Tool to search for a matching class in the WMI Repository. "
Wscript.Echo "USAGE: <keywordToSearch> [<namespaceToSearchIn>]"
Wscript.Echo "Example1: Cscript search.vbs service"
Wscript.Echo "Example2: Cscript search.vbs video root\cimv2"
Else
' If no Namespace is specified then the Default is the ROOT namespace
rootNamespace = "\\.\ROOT"
keyword = args(0)
If args.Count > 1 Then
rootNamespace = args(1)
End If
EnumNameSpace rootNamespace
Wscript.Echo vbNewLine
End if
' Subroutine to recurse through the namespaces
Sub EnumNameSpace(parentNamespaceName)
Set objService = GetObject("winmgmts:" & parentNamespaceName)
Set collMatchingClasses = objService.Execquery _
("Select * From meta_class Where __class " & _
"Like '%" & keyword & "%'")
If (collMatchingClasses.count > 0) Then
Wscript.Echo vbNewLine
Wscript.Echo vbNewLine
Wscript.Echo "Matching Classes Under Namespace: " & parentNamespaceName
For Each matchingClass in collMatchingClasses
Wscript.Echo " " & matchingClass.Path_.CLASS
Next
End if
Set collSubNamespaces = objService.Execquery _
("select * from __namespace")
For Each subNameSpace in collSubNamespaces
EnumNameSpace subNameSpace.path_.namespace + _
"\" + subNameSpace.Name
Next
End Sub
;代码结束======================================================作者: lxmxn 时间: 2006-12-13 02:44
恩,可以了,三个文件全部下载完毕,感谢。作者: HUNRYBECKY 时间: 2006-12-13 02:48 5.在来一个有关WMI CLASS的资料,这个资料同样来源于MS网站,下载地址:http://zhenlove.com.cn/cndos/fileup/files/WMI Classes.rar作者: HUNRYBECKY 时间: 2006-12-13 02:51 6.再来一段关于检查电脑所有脚本版本检测的有关脚本,请把代码保存为version.vbs.双击运行或在CMD下输入 start version.vbs (注意匹配自己的路径)
;代码开始===============================================
On Error Resume Next
WScript.Echo "WSH Version: " & WScript.Version
Wscript.Echo "VBScript Version: " & ScriptEngineMajorVersion _
& "." & ScriptEngineMinorVersion
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\cimv2")
Set colWMISettings = objWMIService.ExecQuery _
("Select * from Win32_WMISetting")
For Each objWMISetting in colWMISettings
Wscript.Echo "WMI Version: " & objWMISetting.BuildVersion
Next
Set objShell = CreateObject("WScript.Shell")
strAdsiVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{E92B03AB-B707-11d2-9CBD-0000F87A369E}\Version")
If strAdsiVersion = vbEmpty Then
strAdsiVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\ADs\Providers\LDAP\")
If strAdsiVersion = vbEmpty Then
strAdsiVersion = "ADSI is not installed."
Else
strAdsiVersion = "2.0"
End If
End If
WScript.Echo "ADSI Version: " & strAdsiVersion
链接地址有脱节的现象,点下去之后不能正确跳转,如果能修正一下就好了。作者: HUNRYBECKY 时间: 2006-12-13 02:58 7.再来传一个WMI的有关工具,这个还是从MS网站上搞下来的.MS把这个东西吹的很好哟.这个实际上是一个HTML文件.我把代码贴上来,请复制所有代码到文本文件中,然后保存为"scriptomatic.hta"双击运行即可.
;代码开始====================================
<html>
<!--********************************************************************
'*
'* File: scriptomatic.hta
'* Created: August 2002
'* Version: 1.0
'*
'* Description: Learning tool. Enables users to generate and run
'* WSH scripts (in VBScript) that use WMI to display
'* properties available through the Win32_ classes.
'*
'*
'* Copyright (C) 2002 Microsoft Corporation
'*
'********************************************************************-->
<title>Windows .NET Server Resource Kit - Scriptomatic</title>
'*********************************************
'* WHILE LOADING...
'*
'* As the application loads, we open a new
'* browser window to act as a crude progress dialog
'* while we wait for the enumeration of the WMI
'* classes to complete.
'*
'* We minimize the parent window prior to presenting
'* the progress dialog and resize it back to normal
'* once the classes are enumerated.
'*
'*********************************************
'****************************************************************************
'* enumerate the WMI classes in the cimv2 namespace, filling up a recordset
'* with the names of the classes that begin with Win32_ and are not association
'* classes. we'll use the class names stored in the recordset to populate a
'* pulldown.
'*****************************************************************************
Set rsDataList = CreateObject("ADODB.Recordset")
rsDataList.Fields.Append "ClassName", adVarChar, MaxCharacters
rsDataList.Open
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
iCounter = 0
For Each objclass in objWMIService.SubclassesOf()
'* write a . to the dialog window once for every 250 classes
'* to let the user know something is still happening.
iCounter = iCounter + 1
If iCounter Mod 250 = 0 Then
objDialogWindow.document.writeln "."
End If
bIsQualifier = False
If UCase(Left(objClass.Path_.Class,5)) = "WIN32" Then
For Each Qualifier in objClass.Qualifiers_
If UCase(Trim(Qualifier.Name)) = "ASSOCIATION" Then
bIsQualifier = True
End If
Next
'* the class name starts with win32_ and is not an association
'* class - so append it to the recordset
If bIsQualifier = False Then
rsDataList.AddNew
rsDataList("ClassName") = objClass.Path_.Class
rsDataList.Update
End If
End If
Next
'* the user hasn't had a chance to select a class and generate
'* a script - so disable the run and save buttons because
'* they are not yet meaningful.
'****************************************************************************
'* when the user selects a class from the pulldown, the ComposeCode subroutine
'* is called. it queries WMI to determine the properties of the class the user
'* selected and uses the information to construct sample code which it puts
'* in the main window's textarea.
'****************************************************************************
Sub ComposeCode
'* if the user happens to select the message instead of a class, just
'* disable the run and save buttons and exit the subroutine
If ClassesPulldown.Value = "PulldownMessage" Then
run_button.disabled = True
save_button.disabled = True
Exit Sub
End If
'****************************************************************************
'* when the user presses the Run button, we use the WshShell object's Run
'* method to run the code currently in the textarea under cscript.exe. we use
'* cmd.exe's /k parameter to ensure the command window remains visible after
'* the script has finished running.
'****************************************************************************
Sub RunScript
Set objFS = CreateObject("Scripting.FileSystemObject")
strTmpName = "temp_script.vbs"
Set objScript = objFS.CreateTextFile(strTmpName)
objScript.Write code.InnerText
objScript.Close
Set objShell = CreateObject("WScript.Shell")
strCmdLine = "cmd /k cscript.exe "
strCmdLine = strCmdLine & strTmpName
objShell.Run(strCmdLine)
End Sub
'****************************************************************************
'* when the user presses the Save button, we present them with an InputBox
'* and force them to give us the full path to where they'd like to the save
'* the script that is currently in the textarea. The user is probably quite
'* upset with our laziness here....and who can blame them?
'****************************************************************************
Sub SaveScript
Set objFSO = CreateObject("Scripting.FileSystemObject")
strSaveFileName = InputBox("Please enter the complete path where you want to save your script (for example, C:\Scripts\MyScript.vbs).")
If strSaveFileName = "" Then
Exit Sub
End If
Set objFile = objFSO.CreateTextFile(strSaveFileName)
objFile.WriteLine code.InnerText
objFile.Close
End Sub
'****************************************************************************
'* when the user presses the Open button, we present them with an InputBox
'* and force them to give us the full path to the script they'd like to open.
'* This is, of course, rather wonky - but it's meant to be.
'****************************************************************************
Sub OpenScript
Set objFSO = CreateObject("Scripting.FileSystemObject")
strOpenFileName = InputBox("Please enter the complete path name for your script (for example, C:\Scripts\MyScript.vbs).")
If strOpenFileName = "" Then
Exit Sub
End If
'****************************************************************************
'* when the user presses the Quit button, the file where we've been storing
'* the scripts gets deleted and the main window closes.
'****************************************************************************
Sub QuitScript
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile "temp_script.vbs"
Set objFSO = Nothing
self.Close()
End Sub
</script>
</head>
'***********************************************************
'* our HTML layout - the only thing of note here is that when
'* each of the buttons is pressed (clicked), their onClick
'* attributes causes the appropriate subroutine to be called
'***********************************************************