China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-29 01:06
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Absolute Good Materials] Complete Collection of WIM WMIC Development Technology Materials (Continuously Updating......) View 11,063 Replies 52
Original Poster Posted 2006-12-13 02:16 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
Recently, I have collected some materials related to WIM and WMIC. Now I will post some here. Those who need them can top the post. If the moderator likes it, it can be highlighted!

Thank you. I don't understand WIM and WIMC. Recently, I heard that this thing is very good. It can cooperate with Windows scripts to complete most system maintenance operations. And I saw a large number of script examples in the script center on the MS website, which I think is of great research value!

According to the suggestion of the brother downstairs, I moved all of them to the top post for easy download. Thank you for the brother's suggestion.

1. "WMI Technology Guide": This is a very good book that is basically out of print. The only scan version available on the Internet is from "MS Technology China". I also obtained this book from the forum moderator of this forum. Thank you to Technology China and also to CN-DOS.
Download address:
http://zhenlove.com.cn/cndos/fileup/files/Wmi技术指南(PDF).rar
2. "WMI Development Documentation" from the MS website, download address is: http://zhenlove.com.cn/cndos/fileup/files/wmisdk(WMI开发文档).rar
3. "WMIC: Comprehensive Management of Windows from the Command Line", collected from the website: download address:
http://zhenlove.com.cn/cndos/fileup/files/WMIC从命令行对Windows的全面管理.rar
4. A script about WMI. This script is from the MS website. The original content has some problems, and it has been slightly corrected. To run this script, please copy the code to Notepad and save it as "search.vbs". Note that you must add quotes when saving, otherwise it will be a text file instead of a script file; then use the command in CMD. The format is as follows: Search.vbs class keyword. This script can realize searching for properties of WMI CLASS.
;Code start =============================================
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> "
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
;Code end =======================================================

5. Relevant materials about WMI CLASSES, from the MS website, download address: http://zhenlove.com.cn/cndos/fileup/files/WMI Classes.rar
For the relevant script for checking the script version detection of all computers, please save the code as version.vbs. Double-click to run or enter start version.vbs in CMD (note to match your own path)
;Code start ================================================
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

;Code end ==========================================
. Then transfer another WMI-related tool. This is also downloaded from the MS website. MS brags about this thing very well. Actually, this is an HTML file. I will post the code here. Please copy all the code to a text file and save it as "scriptomatic.hta", then double-click to run it.
;Code start ====================================
<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>

<HTA:APPLICATION
ID="objScriptomatic"
APPLICATIONNAME="Scriptomatic"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
>
<head>

<style>
BODY
{
background-color: buttonface;
font-family: Helvetica;
font-size: 8pt;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
margin-bottom: 10px;
}


.button
{
font-family: Helvetica;
font-size: 8pt;
width: 35px;
}

textarea
{
font-family: arial;
font-size: 8pt;
margin-left: 3px;
}

select
{
font-family: arial;
font-size: 8pt;
width: 450px;
margin-left: 0px;
}

</style>

<script language="vbscript">

'*********************************************
'* 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.
'*
'*********************************************

Sub Window_Onload

'* resize parent window

self.ResizeTo 1,1
self.MoveTo 300,300

'* create dialog window

Set objDialogWindow = window.Open("about:blank","ProgressWindow","height=15,width=250,left=300,top=300,status=no,titlebar=no,toolbar=no,menubar=no,location=no,scrollbars=no")
objDialogWindow.Focus()
objDialogWindow.ResizeTo 250,15
objDialogWindow.document.body.style.fontFamily = "Helvetica"
objDialogWindow.document.body.style.fontSize = "11pt"
objDialogWindow.document.writeln "<html><body>Loading WMI Classes.</body></html>"
objDialogWindow.document.title = "Please wait."
objDialogWindow.document.body.style.backgroundColor = "buttonface"
objDialogWindow.document.body.style.borderStyle = "none"
objDialogWindow.document.body.style.marginTop = 15

'****************************************************************************
'* 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.
'*****************************************************************************

Const adVarChar = 200
Const MaxCharacters = 255
strComputer = "."

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

'* populate the pulldown

rsDataList.Sort = "ClassName"
rsDataList.MoveFirst
strHTML = "<select onChange=""ComposeCode()"" name=ClassesPulldown>" &_
"<option value=""PulldownMessage"">Begin by selecting a class"
Do Until rsDataList.EOF
strHTML = strHTML & "<option value= " & chr(34) &_
rsDataList.Fields.Item("ClassName") & chr(34) &_
">" & rsDataList.Fields.Item("ClassName")
rsDataList.MoveNext
Loop
strHTML = strHTML & "</select>"
wmi_classes.insertAdjacentHTML "beforeEnd", strHTML


'* the classes are enumerated, close the progress dialog
'* and resize the main window

objDialogWindow.Close
self.Focus()
self.ResizeTo 670,550
self.MoveTo 200,200

'* 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.

run_button.disabled = True
save_button.disabled = True

End Sub

'****************************************************************************
'* 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

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objClass = objWMIService.Get(ClassesPulldown.Value)
strHTML = "<textarea cols=100 rows=30>"
strHTML = strHTML & "On Error Resume Next" & Chr(10)
strHTML = strHTML & "strComputer = " & chr(34) & "." & chr(34) & Chr(10)
strHTML = strHTML & "Set objWMIService = GetObject(" & chr(34) & "winmgmts:\\" & chr(34) & " & strComputer & " & chr(34) & "\root\cimv2" & chr(34) & ")" & Chr(10)
strHTML = strHTML & "Set colItems = objWMIService.ExecQuery(" & chr(34) & "Select * from " & ClassesPulldown.value & chr(34) & ",,48)" & Chr(10)
strHTML = strHTML & "For Each objItem in colItems" & Chr(10)
For Each objProperty in objClass.properties_
strHTML = strHTML & "&nbsp; &nbsp; Wscript.Echo " & chr(34) & objProperty.name & ": " & chr(34) & " & " & "objItem." & objProperty.name & Chr(10)
Next
strHTML = strHTML & "Next" & "</textarea>"
code.InnerHTML= strHTML

'* once the code is successfully composed and put into the textarea, ensure
'* that the run and save buttons are enabled

run_button.disabled = False
save_button.disabled = False

End Sub

'****************************************************************************
'* 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

Set objFile = objFSO.OpenTextFile(strOpenFileName)
strHTML = "<textarea cols=100 rows=30>"
strHTML = strHTML & objFile.ReadAll()
strHTML = strHTML & "</textarea>"
code.InnerHTML = strHTML
objFile.Close
run_button.disabled = False
save_button.disabled = False

End Sub

'****************************************************************************
'* 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
'***********************************************************

<body>

<table>
<td>
<span id="wmi_classes">&nbsp;</span>
<input id=runbutton class="button" type="button" value="Run" name="run_button" onClick="RunScript()">
<input id=savebutton class="button" type="button" value="Save" name="save_button" onClick="SaveScript()">
<input id=openbutton class="button" type="button" value="Open" name="open_button" onClick="OpenScript()">
<input id=quitbutton class="button" type="button" value="Quit" name="quit_button" onClick="QuitScript()">
<div ID=code_header></div>
<div id="code"></div>
</td>
</tr>
</table>



</body>

</html>

;Code end ==============================================
9. Then another WMI script tutorial. This is also collected from the Internet. I don't remember the download address. It seems that the fourth chapter is missing. You can search on the Internet by yourself. It seems that there is also on the MS website. The address is http://www.microsoft.com/china/M ... inicscripting.mspx.

Download address: http://zhenlove.com.cn/cndos/fileup/files/wmi脚本入门(pdf不完整).rar

8. Then another WMI query analysis tool. It is from a foreign website. It is equipped with source code. Those who don't download will regret it. However, I can't run this program on my computer. I don't know why. Everyone test and feedback what the problem is. Thank you.
Download address:
http://zhenlove.com.cn/cndos/fileup/files/WQLAnalyzer_1.02(wmi查询分析工具有源代码).zip

10. "Windows WMI Reference". Since this can only be read on the Internet and no relevant e-book download is found, so all the captured web pages are sent. The number in front of the name represents the chapter number, such as 0101 represents the first chapter and the first section, and 050105 represents the fifth chapter - the first section - the first sub-section.
Download address:
http://zhenlove.com.cn/cndos/fileup/files/windowswmi参考.rar
11. "WMI Development Toolkit". This is directly downloaded from the MS website. It has already included the previous wmisdk(WMI Development Documentation).rar, so those who download this can no longer download the above one.
http://zhenlove.com.cn/cndos/fileup/files/
wmisdk(WMI开发工具包).rar

[ Last edited by HUNRYBECKY on 2006-12-18 at 12:06 PM ]
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
namejm +8 2006-12-13 02:54
lxmxn +9 2006-12-13 03:28
redtek +7 2006-12-14 21:26
tyh +1 2007-04-23 04:43
Floor 2 Posted 2006-12-13 02:17 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
I'm sorry, I dropped one.
The download address of the "WMI Development Document" development document is: http://zhenlove.com.cn/cndos/fileup/files/wmisdk(WMI development document).rar
Floor 3 Posted 2006-12-13 02:21 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Downloading...

  It is recommended to also post the download link for the "WMI Development Technical Documentation". I don't know how much content about WMIC is in it yet, because this is a command-line command, so it's better to mainly post content about WMIC. It would be best if the WMI includes the content of WMIC.
Floor 4 Posted 2006-12-13 02:22 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Sweat a bit first...
  
  Sent one step late.
Floor 5 Posted 2006-12-13 02:23 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
WMI includes WMIC. So you can download it.
Floor 6 Posted 2006-12-13 02:26 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
3. "WMIC: Comprehensive Management of Windows from the Command Line": Adding one more. This was collected from the internet, and I don't know where it was downloaded from.

Download link:
http://zhenlove.com.cn/cndos/fileup/files/WMICWMIC Comprehensive Management of Windows from the Command Line.rar
Floor 7 Posted 2006-12-13 02:28 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
The upload system here is so slow. It took me two hours to upload "WMI Technical Guide".
Floor 8 Posted 2006-12-13 02:29 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

The link in floor 2 cannot be downloaded, indicating that the resource is not found.
Floor 9 Posted 2006-12-13 02:30 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  The same problem on floor 6.
Floor 10 Posted 2006-12-13 02:32 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
The uploads below the 2nd floor are still in progress. Because the upload system said: the part before the download address remains unchanged, and the part after is the file name, so it should be connectable after the upload is completed. If not, inform me to make corrections.
Floor 11 Posted 2006-12-13 02:34 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Oh my god, you posted the address before it was completely uploaded? Let's take a sweat first...
Floor 12 Posted 2006-12-13 02:35 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
The second floor has been uploaded, and the link is indeed correct. I'm sorry, it's very slow for me to upload here, so I'll post first. Hehe, it's too hard to wait.
Floor 13 Posted 2006-12-13 02:44 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
4. Another script about WMI, this script is from the MS website. The original content had some issues, which have been slightly corrected. To run this script, copy the code into Notepad and save it as "search.vbs". Note that you must add quotes when saving, otherwise it will be a text file instead of a script file. Then, in CMD, use the command in the following format: Search.vbs class keyword. This script can implement searching for properties, etc. of WMI CLASS.
; Code starts =============================================
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
; Code ends ======================================================
Floor 14 Posted 2006-12-13 02:44 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  Okay, it's done. All three files have been downloaded. Thanks.
Floor 15 Posted 2006-12-13 02:48 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,179
Posts 442
Joined 2006-09-09 22:47
19-year member
UID 62249
Status Offline
5. Another piece of information about WMI CLASS, this information also comes from the MS website, download address: http://zhenlove.com.cn/cndos/fileup/files/WMI Classes.rar
Forum Jump: