<html>
<head>
<title>WMI Code Generator</title>
<HTA:APPLICATION
ID="WMIGen"
VERSION="7.03"
APPLICATIONNAME="WMI Code Generator"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
<style type="text/css">
<!--
a { color: blue; }
p { color: black; font-size: 80%; }
.Button { width: 12em; margin: 3px 1em 3px 1em; }
.Red { color: red; }
.White { color: white; }
-->
</style>
</head>
<script language="VBScript">
Option Explicit
' Variable to make the generated code either resource friendly or versatile
' If True then the generated code is resource friendly, but "read-once"
' If False then the generated code is more versatile, but may use more resources
' Command line switch /RESOURCEFRIENDLY sets variable to True
Dim gvbResourceFriendly
gvbResourceFriendly = False
' Variable to set filter for classes shown
' If True then all classes are shown
' If False then only WIN32_* classes are shown
' Command line switch /WIN32 sets variable to False
Dim gvbShowAllClasses
gvbShowAllClasses = True
' Variable to set filter for Win32_Perf* classes
' If True then the Win32_Perf* classes are included
' If False then the Win32_Perf* classes are excluded
' Command line switch /NOPERF sets variable to False
Dim gvbShowPerfClasses
gvbShowPerfClasses = True
' Variable to tell if the program should check for updates at startup
' If True then a check for updates is performed at startup
' If False then the check is skipped
' Command line switch /NOUPDCHK sets variable to False
Dim gvbUpdateCheck
gvbUpdateCheck = True
' Variable to choose between original property names or property names with spaces
' If True then property names WITH spaces are used for descriptions
' If False then the original property names WITHOUT spaces are used
' Command line swith /SPACES sets variable to True
Dim gvbUseSpacesInProperties
gvbUseSpacesInProperties = False
' Variable determining (soft) word wrap vs. no word wrap in the generated code field
' If True then soft word wrap is used
' If False then no word wrap is used
' Command line swith /WRAP sets variable to True
Dim gvbWordWrap
gvbWordWrap = False
' Variable to hold the selected WMI namespace (default: root/CIMV2)
' Optional command line swith /NAMESPACE:"root/new_namespace" sets new namespace, e.g. /NAMESPACE:"root/WMI"
' Use doublequotes to prevent misinterpretation of the text following the forward slash
Dim gvsNameSpace
gvsNameSpace = "root/CIMV2"
' Variable to determine if the namespace and class lists should be skipped
' If True then the namespace and (if class is specified on the command line) class "list" is populated only with the values given on the command line
' If False then the namespaces and classes are listed using WMI queries
' This feature requires the use of the /NAMESPACE parameter
' Command line swith /FAST sets variable to True
Dim gvbFast
gvbFast = False
' More global variables
Dim gvaNameSpaces( )
Dim gvbClassValidate
Dim gvbCmdLineValidate
Dim gvbLanguageValidate
Dim gvbNameSpaceValidate
Dim gviReqHeight
Dim gviReqWidth
Dim gvoIEHelp
Dim gvsClass
Dim gvsCmdLine
Dim gvsLanguage
gvsCmdLine = UCase( WMIGen.CommandLine )
gvbCmdLineValidate = True
gvbClassValidate = True
gvbLanguageValidate = True
gvbNameSpaceValidate = True
gviReqHeight = window.screen.height
gviReqWidth = window.screen.width
Sub ButtonState( )
If Trim( Code.Value ) = "" Then
CodeLabel.innerHTML = "Code:"
CopyCodeButton.Disabled = True
CopyCodeButton.Title = ""
ClearCodeButton.Disabled = True
ClearCodeButton.Title = ""
Else
CopyCodeButton.Disabled = False
CopyCodeButton.Title = "Press this button to copy the generated code to the clipboard"
ClearCodeButton.Disabled = False
ClearCodeButton.Title = "Press this button to erase the generated code"
End If
End Sub
Sub CheckUpdate( )
If gvbUpdateCheck Then
Dim lenLatestVer, strCurrentVer, strLatestver, wshShell
' Change mouse pointer to hourglass while checking for update
Document.Body.Style.Cursor = "wait"
strCurrentVer = WMIGen.Version
strLatestVer = TextFromHTML( "http://www.robvanderwoude.com/updates/wmigen.txt" )
If strCurrentVer <> strLatestver Then
' Clear the IE cache
Set wshShell = CreateObject( "WScript.Shell" )
wshShell.Run "RUNDll32.EXE InetCpl.cpl,ClearMyTracksByProcess 8", 7, True
Set wshShell = Nothing
' Try again, read the latest version info from the web
strLatestver = TextFromHTML( "http://www.robvanderwoude.com/updates/wmigen.txt" )
End If
lenLatestVer = Len( strLatestVer )
If lenLatestVer = 4 Then
If strLatestVer < strCurrentVer Then
Update.InnerHTML = "<p class=""White"">You seem to be using a pre-release version (" & strCurrentVer _
& ") of the WMI Code Generator.<br>The latest stable release is " _
& strLatestVer & " and it is available " _
& "<a href=""http://www.robvanderwoude.com/wmigen.php"" class=""Red"">here</a>.</p>"
Update.style.border = "2px solid white"
Update.style.display = "block"
End If
If strLatestVer > strCurrentVer Then
Update.InnerHTML = "<p class=""White"">You are using version " & strCurrentVer _
& " of the WMI Code Generator.<br>An update to version " _
& strLatestVer & " is available " _
& "<a href=""http://www.robvanderwoude.com/wmigen.php"" class=""Red"">here</a>.</p>"
Update.style.border = "2px solid red"
Update.style.display = "block"
End If
End If
' Change mouse pointer back to default
Document.Body.Style.Cursor = "default"
End If
End Sub
Sub CheckWindowSize( )
Dim codeBoxRows, largeBoxWidth, smallBoxHeight, smallBoxWidth
If InStr( gvsCmdLine, "/SIZE:" ) > 0 Then WxH InStr( gvsCmdLine, "/SIZE:" ) + 5
largeBoxWidth = CInt( Document.Body.ClientWidth / 9 )
smallBoxWidth = CInt( ( largeBoxWidth - 5 ) / 2 )
smallBoxHeight = CInt( Document.Body.ClientHeight / 100 )
codeBoxRows = CInt( Document.Body.ClientHeight / 50 )
If smallBoxHeight < 6 Then smallBoxHeight = 6
If codeBoxRows < 15 Then codeBoxRows = 15
Code.Cols = largeBoxWidth
Code.Rows = codeBoxRows
Properties.size = smallBoxHeight
Methods.size = smallBoxHeight
WMIClasses.size = smallBoxHeight
End Sub
Sub ClearCode( )
Code.Value = ""
ButtonState
End Sub
Sub CopyCode( )
Document.ParentWindow.ClipboardData.SetData "text", Code.Value
End Sub
Sub CreateIEHelp( )
On Error Resume Next
gvoIEHelp.Close
Set gvoIEHelp = Nothing
Set gvoIEHelp = CreateObject( "InternetExplorer.Application" )
gvoIEHelp.Navigate "about:blank"
gvoIEHelp.AddressBar = 1
gvoIEHelp.MenuBar = 1
gvoIEHelp.StatusBar = 1
gvoIEHelp.ToolBar = 1
gvoIEHelp.Top = 0
gvoIEHelp.Left = 0
gvoIEHelp.Width = window.width
gvoIEHelp.Height = window.height
gvoIEHelp.TheaterMode = 0
gvoIEHelp.Visible = 1
On Error Goto 0
End Sub
Function CreateLine( myProperty, myMaxLen )
' This subroutine will split up a string into separate words if command line switch /SPACES is used:
' "SCSILogicalUnit" will be converted to "SCSI Logical Unit"
Dim colMatches, intMatches, maxLen, objRE
On Error Resume Next
maxLen = myMaxLen
If gvbUseSpacesInProperties Then
maxLen = maxLen + 5
Set objRE = New RegExp
objRE.Global = False
objRE.IgnoreCase = False
' Insert a space between lowwercase and immediately following uppercase letters
objRE.Pattern = "([a-z])([A-Z])"
intMatches = -1
Do Until intMatches = 0
Set colMatches = objRE.Execute( myProperty )
intMatches = colMatches.Count
If intMatches > 0 Then
myProperty = objRE.Replace( myProperty, colMatches(0).Submatches(0) & " " & colMatches(0).Submatches(1) )
End If
Loop
' Insert a space between the second last and last uppercase letters in a row of uppercase only
objRE.Pattern = "([A-Z]+)([A-Z][a-z])"
intMatches = -1
Do Until intMatches = 0
Set colMatches = objRE.Execute( myProperty )
intMatches = colMatches.Count
If intMatches > 0 Then
myProperty = objRE.Replace( myProperty, colMatches(0).Submatches(0) & " " & colMatches(0).Submatches(1) )
End If
Loop
Set objRE = Nothing
End If
On Error Goto 0
CreateLine = Left( myProperty & Space( maxLen ), maxLen ) & " :"
End Function
Sub Credits( )
Dim strHTML
strHTML = "<p><strong>WMI Code Generator, Version " & WMIGen.Version & "</strong></p>" _
& vbCrLf & vbCrLf _
& "<p>© 2011 Rob van der Woude<br>" _
& vbCrLf _
& "<a href=""http://www.robvanderwoude.com/wmigen.php"">http://www.robvanderwoude.com/wmigen.php</a></p>" _
& vbCrLf & vbCrLf _
& "<p> </p>" _
& vbCrLf & vbCrLf _
& "<h1>Credits:</h1>" _
& vbCrLf & vbCrLf _
& "<p>Based on the Microsoft TechNet ScriptCenter article <a href=""http://www.microsoft.com/technet/scriptcenter/resources/guiguy/default.mspx"">Scripting Eye for the GUI Guy</a>.</p>" _
& vbCrLf _
& "<p>Created with the help of WBEMTEST, the Scripting Guys' <a href=""http://www.microsoft.com/technet/scriptcenter/tools/scripto2.mspx"">Scriptomatic</a> and <a href=""http://www.microsoft.com/downloads/details.aspx?FamilyId=231D8143-F21B-4707-B583-µ7B9152E6D9"">HTA Helpomatic</a> tools, and Adersoft's <a href=""http://www.htµdit.com/"">HTµdit</a>.</p>" _
& vbCrLf _
& "<p>Java code based on a <a href=""http://www.dreamincode.net/code/snippet3297.htm"">JACOB sample</a> by 'NickDMax' on DreamInCode.net.</p>" _
& vbCrLf _
& "<p>Object Rexx code based on the Rexx script samples found at Microsoft's <a href=""http://www.microsoft.com/technet/scriptcenter/scripts/rexx/default.mspx?mfr=true"">Script Repository</a>; tested with <a href=""http://www.oorexx.org/"">Open Object Rexx</a>.</p>" _
& vbCrLf _
& "<p>Ruby code based on David Mullet's blog posting <a href=""http://rubyonwindows.blogspot.com/2007/07/using-ruby-wmi-to-get-win32-process.html"">Using Ruby & WMI to Get Win32 Process Information</a>.</p>" _
& vbCrLf _
& "<p>MSDN Help search function based on <a href=""http://www.google.com/"">Google Search</a> and completed with help from <a href=""http://www.seroundtable.com/archives/015944.html"">Search Engine Roundtable</a>.</p>"
On Error Resume Next
gvoIEHelp.Navigate "about:blank"
If Err.Number Then
CreateIEHelp
gvoIEHelp.Navigate "about:blank"
End If
On Error Goto 0
gvoIEHelp.Width = Min( gviReqWidth, 1024 )
gvoIEHelp.Height = Min( gviReqHeight, 768 )
gvoIEHelp.Left = Int( ( window.screen.width - gvoIEHelp.Width ) / 2 )
gvoIEHelp.Top = Int( ( window.screen.height - gvoIEHelp.Height ) / 2 )
gvoIEHelp.StatusBar = False
gvoIEHelp.AddressBar = False
gvoIEHelp.MenuBar = False
gvoIEHelp.ToolBar = False
gvoIEHelp.Document.Title = "WMI Code Generator " & WMIGen.Version
gvoIEHelp.Document.Body.style.fontFamily = "arial,sans-serif"
gvoIEHelp.Document.Body.InnerHTML = strHTML
gvoIEHelp.Visible = 1
End Sub
Sub EnumNameSpaces( myNameSpace )
Dim colNameSpaces, intSize, objNameSpace, objWMIService
intSize = UBound( gvaNameSpaces )
Set objWMIService = GetObject ( "winmgmts:{impersonationLevel=impersonate}//./" & myNameSpace )
Set colNameSpaces = objWMIService.InstancesOf( "__NAMESPACE" )
For Each objNameSpace In colNameSpaces
If Left( objNameSpace.Name, 2 ) <> "__" Then
intSize = UBound( gvaNameSpaces ) + 1
ReDim Preserve gvaNameSpaces( intSize )
gvaNameSpaces( intSize ) = myNameSpace & "/" & objNameSpace.Name
EnumNameSpaces myNameSpace & "/" & objNameSpace.Name
End If
Next
End Sub
Sub FillClassDropDown( )
' Bubble sort algorithm found in Microsoft's Script Repository
' http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1122.mspx
Dim arrClasses( ), blnCheck, colClasses, intSize, i, j, k, objClass, objNewOption, objWMIService, strHolder
intSize = 0
' Change cursor to hourglass while loading WMI class list
Document.Body.Style.Cursor = "wait"
' Enable custom error handling
On Error Resume Next
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
If Err Then
MsgBox "Could not connect to " & gvsNameSpace, vbOKOnly, "NameSpace Error"
Exit Sub
End If
If gvsClass <> "" And gvbFast Then
ReDim arrClasses(0)
arrClasses(0) = gvsClass
Else
Set colClasses = objWMIService.SubClassesOf
If Err Then
MsgBox "Error " & Err.Number & ": " & Err.Description, vbOKOnly, "Error"
Exit Sub
End If
' Store the list of classes in an array
For Each objClass In colClasses
' List only Win32_* classes if /WIN32 was used
If Left( UCase( objClass.Path_.Class ), 6 ) = "WIN32_" Or gvbShowAllClasses Then
' Skip Win32_Perf* classes if /NOPERF was used
If Left( UCase( objClass.Path_.Class ), 10 ) <> "WIN32_PERF" Or gvbShowPerfClasses Then
' Skip WMI systemm properties starting with a double underscore
If Left( objClass.Path_.Class, 2 ) <> "__" Then
ReDim Preserve arrClasses( intSize )
arrClasses( intSize ) = objClass.Path_.Class
intSize = intSize + 1
End If
End If
End If
Next
End If
If IsArray( arrClasses ) Then
If UBound( arrClasses ) > 1 Then
' Sort the classes
For i = ( UBound( arrClasses ) - 1 ) To 0 Step -1
For j= 0 to i
k = j + 1
If UCase( arrClasses(j) ) > UCase( arrClasses(k) ) Then
strHolder = arrClasses(k)
arrClasses(k) = arrClasses(j)
arrClasses(j) = strHolder
End If
Next
Next
End if
' Purge the classes list
WMIClasses.InnerHTML = ""
' Populate the classes list
If gvsClass = "" Then
blnCheck = True
Else
blnCheck = False
End If
For i = 0 To UBound( arrClasses )
Set objNewOption = document.createElement( "OPTION" )
If CInt( i / 2 ) <> ( i / 2 ) Then
objNewOption.style.backgroundcolor = "#F0F0F0"
End If
objNewOption.Text = arrClasses(i)
If gvsClass = "" Then
If i = 0 Then
objNewOption.Selected = True
End If
Else
If UCase( arrClasses(i) ) = gvsClass Then
objNewOption.Selected = True
blnCheck = True
End If
End If
WMIClasses.options.Add( objNewOption )
Next
If Not blnCheck Then
gvbCmdLineValidate = False
gvbClassValidate = False
End If
End If
' Change cursor back to default
Document.Body.Style.Cursor = "default"
On Error Goto 0
HandleClassChange
End Sub
Sub FillNameSpacesDropDown( )
' Bubble sort algorithm found in Microsoft's Script Repository
' http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1122.mspx
Dim blnCheck, intSize, i, j, k, objNameSpace, objNewOption, strHolder
intSize = 0
' Change cursor to hourglass while loading WMI class list
Document.Body.Style.Cursor = "wait"
' Enable custom error handling
On Error Resume Next
If gvbFast Then
ReDim gvaNameSpaces(0)
gvaNameSpaces(0) = gvsNameSpace
Else
' Get a list of available namespaces
ReDim Preserve gvaNameSpaces(0)
gvaNameSpaces(0) = "root"
EnumNameSpaces( "root" )
' Sort the array of namespaces
If UBound( gvaNameSpaces ) > 1 Then
For i = UBound( gvaNameSpaces ) - 1 To 0 Step -1
For j= 0 to i
k = j + 1
If UCase( gvaNameSpaces(j) ) > UCase( gvaNameSpaces(k) ) Then
strHolder = gvaNameSpaces(k)
gvaNameSpaces(k) = gvaNameSpaces(j)
gvaNameSpaces(j) = strHolder
End If
Next
Next
End If
End If
' Populate the namespaces list
If gvsNameSpace = "" Then
blnCheck = True
Else
blnCheck = False
End If
For i = 0 To UBound( gvaNameSpaces )
Set objNewOption = document.createElement( "OPTION" )
If CInt( i / 2 ) <> ( i / 2 ) Then
objNewOption.style.backgroundcolor = "#F0F0F0"
End If
objNewOption.Text = gvaNameSpaces(i)
If gvsNameSpace = "" Then
If i = 0 Then
objNewOption.Selected = True
End If
Else
If UCase( objNewOption.Text ) = UCase( gvsNameSpace ) Then
objNewOption.Selected = True
gvsNameSpace = objNewOption.Text
blnCheck = True
End If
End If
NameSpaces.options.Add( objNewOption )
Next
If Not blnCheck Then
gvbCmdLineValidate = False
gvbNameSpaceValidate = False
End If
' Change cursor back to default
Document.Body.Style.Cursor = "default"
On Error Goto 0
HandleClassChange
End Sub
Sub GetHelp( )
Dim objOption, strClass, strMember, urlHelp
' Check which class is selected
For Each objOption In WMIClasses.options
If objOption.Selected = True Then
strClass = Trim( objOption.Text)
End If
Next
' Check which Property is selected, if any
strMember = ""
For Each objOption In Properties.options
If objOption.Selected = True Then
strMember = "+" & Trim( objOption.Text ) & "+property"
End If
Next
' Check which Method is selected, if any
For Each objOption In Methods.options
If objOption.Selected = True Then
strMember = "+" & Trim( objOption.Text ) & "+method"
End If
Next
' Google search techniques learned from
' http://www.seroundtable.com/archives/015944.html
urlHelp = "http://www.google.com/search?q=" & strClass & strMember & "&site=msdn.microsoft.com&btnI=745&pws=0"
On Error Resume Next
gvoIEHelp.Navigate urlHelp
If Err.Number Then
CreateIEHelp
gvoIEHelp.Navigate urlHelp
End If
On Error Goto 0
gvoIEHelp.Visible = 1
End Sub
Sub HandleClassChange( )
Dim arrMethods( ), arrProperties( )
Dim intMethods, intProperties, i, j, k
Dim objClass, objMethod, objNewOption, objOption, objProperty, objWMIService
Dim strClass, strHolder, strOption
' Purge the Methods list
For Each objMethod in Methods.options
objMethod.RemoveNode
Next
ReDim arrMethods( 0 )
intMethods = 0
' Purge the Properties list
For Each objProperty in Properties.options
objProperty.RemoveNode
Next
ReDim arrProperties( 0 )
intProperties = 0
' Change cursor to hourglass while loading the class' members lists
Document.Body.Style.Cursor = "wait"
For Each objOption In WMIClasses.Options
If objOption.Selected = True Then
strClass = objOption.Text
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( strClass )
' Store the list of methods in an array
For Each objMethod In objClass.Methods_
ReDim Preserve arrMethods( intMethods )
arrMethods( intMethods ) = objMethod.Name
intMethods = intMethods + 1
Next
If IsArray( arrMethods ) Then
' Sort the methods list
For i = ( UBound( arrMethods ) - 1 ) to 0 Step -1
For j= 0 to i
k = j + 1
If UCase( arrMethods(j) ) > UCase( arrMethods(k) ) Then
strHolder = arrMethods(k)
arrMethods(k) = arrMethods(j)
arrMethods(j) = strHolder
End If
Next
Next
End If
' Populate the Methods list
i = 0
For Each strOption in arrMethods
Set objNewOption = document.createElement( "OPTION" )
If CInt( i / 2 ) <> ( i / 2 ) Then
objNewOption.style.backgroundcolor = "#F0F0F0"
End If
objNewOption.Text = strOption
Methods.options.Add( objNewOption )
i = i + 1
Next
' Store the list of properties in an array
For Each objProperty In objClass.Properties_
ReDim Preserve arrProperties( intProperties )
arrProperties( intProperties ) = objProperty.Name
intProperties = intProperties + 1
Next
If IsArray( arrProperties ) Then
' Sort the properties list
For i = ( UBound( arrProperties ) - 1 ) to 0 Step -1
For j= 0 to i
k = j + 1
If UCase( arrProperties(j) ) > UCase( arrProperties(k) ) Then
strHolder = arrProperties(k)
arrProperties(k) = arrProperties(j)
arrProperties(j) = strHolder
End If
Next
Next
End If
' Populate the Properties list
i = 0
For Each strOption in arrProperties
Set objNewOption = document.createElement( "OPTION" )
If CInt( i / 2 ) <> ( i / 2 ) Then
objNewOption.style.backgroundcolor = "#F0F0F0"
End If
objNewOption.Text = strOption
Properties.options.Add( objNewOption )
i = i + 1
Next
End If
Next
' Change cursor back to default
Document.Body.Style.Cursor = "default"
Code.Value = ""
ButtonState
End Sub
Sub HandleLanguageChange( )
If Trim( Code.value ) = "" Then
ButtonState
Code.Value = ""
Else
ShowCode
End If
End Sub
Sub HandleNameSpaceChange( )
Dim objOption
WMIClasses.InnerHTML = ""
Code.value = ""
Methods.innerHTML = ""
Properties.innerHTML = ""
ButtonState
For Each objOption In NameSpaces.Options
If objOption.Selected = True Then
gvsNameSpace = objOption.Text
End If
Next
FillClassDropDown
End Sub
Sub HelpMsg( )
Dim strHTML
strHTML = "<p><strong>WMI Code Generator, Version " & WMIGen.Version & "</strong></p>" _
& vbCrLf & vbCrLf _
& "<p>Interactively generate source code in the selected scripting or programming language, for a selected WMI query</p>" _
& vbCrLf & vbCrLf _
& "<table style=""font-size: 10pt;"">" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td style=""vertical-align: top""><strong>Usage:</strong></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"" colspan=""3""><code>WMIGEN.HTA [ options ]</code></td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""5""> </td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td style=""vertical-align: top""><strong>Options:</strong></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/HELP</code> or <code>/?</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Show this message</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/SIZE:WxH</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Center window and resize to W x H pixels</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/NOUPDCHK</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Skip check for updates at startup</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/NAMESPACE:""namespace""</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Specifies the initial WMI namespace to be opened (default: <code>root/CIMV2</code>)</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/CLASS:""class""</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Specifies the WMI class to be selected</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/WIN32</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">List <code>Win32_*</code> classes only</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/NOPERF</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Exclude <code>Win32_Perf*</code> classes</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/LANGUAGE:""language""</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Specifies the initial programming or script language; ""language"" value as listed in drop-down box, but <em>without spaces</em> (default: Batch)</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/RESOURCEFRIENDLY</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Generate code that uses less resources, at the cost of being ""read-once"" only (ignored for C#, F#, Java, PowerShell and VB.NET)</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/SPACES</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Insert spaces in property name descriptions, e.g. ""<code>SCSI Logical Unit</code>"" instead of ""<code>SCSILogicalUnit</code>""</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/WRAP</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Enable (soft) word wrap in the generated code field</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/FAST</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Skip the queries to populate the namespaces and (if specified) classes lists, and ""populate"" these lists with the values specified on the command line only (requires <code>/NAMESPACE</code> parameter; without <code>/CLASS</code> parameter, the classes list will still be populated using a WMI query)</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/GENERATE</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Generate the code immediately (requires <code>/NAMESPACE</code>, <code>/CLASS</code> and <code>/LANGUAGE</code> parameters)</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/RUN</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Run the generated VBScript code immediately (requires <code>/NAMESPACE</code> and <code>/CLASS</code> parameters)</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top""><code>/COPY</code></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td style=""vertical-align: top"">Copy the generated code or result to the clipboard and exit (requires <code>/NAMESPACE</code>, <code>/CLASS</code>, and either <code>/LANGUAGE</code> and <code>/GENERATE</code> or <code>/RUN</code> parameters)</td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""5""> </td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td style=""vertical-align: top""><strong>Examples:</strong></td>" _
& vbCrLf _
& " <td> </td>" _
& vbCrLf _
& " <td colspan=""3"" style=""vertical-align: top""><code>WMIGEN.HTA /Win32 /NoPerf /Size:1024x768</code></td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td colspan=""3"" style=""vertical-align: top""><code>WMIGEN.HTA /NameSpace:""root/SecurityCenter2""</code></td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "<tr>" _
& vbCrLf _
& " <td colspan=""2""> </td>" _
& vbCrLf _
& " <td colspan=""3"" style=""vertical-align: top""><code>WMIGEN.HTA /NoUpdChk /NameSpace:""root/WMI"" /Class:""WmiMonitorID"" /Language:""Java"" /Generate /Copy /Fast<br>" _
& vbCrLf _
& " <a href=""http://www.robvanderwoude.com/csharpexamples.php#Paste"">PASTE.EXE</a> > WMIGen_WmiMonitorID.java</code></td>" _
& vbCrLf _
& "</tr>" _
& vbCrLf _
& "</table>" _
& vbCrLf & vbCrLf _
& "<p>© 2011 Rob van der Woude<br>" _
& vbCrLf _
& "<a href=""http://www.robvanderwoude.com/wmigen.php"">http://www.robvanderwoude.com/wmigen.php</a></p>"
On Error Resume Next
gvoIEHelp.Navigate "about:blank"
If Err.Number Then
CreateIEHelp
gvoIEHelp.Navigate "about:blank"
End If
On Error Goto 0
gvoIEHelp.Width = Min( gviReqWidth, 1024 )
gvoIEHelp.Height = Min( gviReqHeight, 768 )
gvoIEHelp.Left = Int( ( window.screen.width - gvoIEHelp.Width ) / 2 )
gvoIEHelp.Top = Int( ( window.screen.height - gvoIEHelp.Height ) / 2 )
gvoIEHelp.StatusBar = False
gvoIEHelp.AddressBar = False
gvoIEHelp.MenuBar = False
gvoIEHelp.ToolBar = False
gvoIEHelp.Document.Title = "WMI Code Generator " & WMIGen.Version
gvoIEHelp.Document.Body.style.fontFamily = "arial,sans-serif"
gvoIEHelp.Document.Body.InnerHTML = strHTML
gvoIEHelp.Visible = 1
End Sub
Function Max( num1, num2 )
If num1 > num2 Then
Max = num1
Else
Max = num2
End If
End Function
Function Min( num1, num2 )
If num1 < num2 Then
Min = num1
Else
Min = num2
End If
End Function
Sub OnClickCheckboxExcludPerf()
If Exclude_Perf.checked Then
gvbShowPerfClasses = False
Else
gvbShowPerfClasses = True
End If
FillClassDropDown
End Sub
Sub OnClickCheckboxHideUpdate()
If Hide_Update.checked Then
Update.style.display = "none"
Else
Update.style.display = "block"
If gvbUpdateCheck = False Then
gvbUpdateCheck = True
CheckUpdate
End If
End If
End Sub
Sub OnClickCheckboxResourceFriendly()
If Resource_Friendly.checked Then
gvbResourceFriendly = True
Else
gvbResourceFriendly = False
End If
If Code.Value <> "" Then ShowCode
End Sub
Sub OnClickCheckboxUseSpaces()
If Use_Spaces.checked Then
gvbUseSpacesInProperties = True
Else
gvbUseSpacesInProperties = False
End If
If Code.Value <> "" Then ShowCode
End Sub
Sub OnClickCheckboxWin32_Only()
If Win32_Only.checked Then
gvbShowAllClasses = False
Else
gvbShowAllClasses = True
End If
FillClassDropDown
End Sub
Sub OnClickCheckboxWordWrap()
If Word_Wrap.checked Then
gvbWordWrap = True
Code.wrap = "soft"
Else
gvbWordWrap = False
Code.wrap = "off"
End If
End Sub
Sub RunCode( )
Dim i, maxLen
Dim colItems, objItem, objOption, objProperty, objWMIService
Dim strClass, strCode, strProperty
' Set word wrap
If gvbWordWrap Then
Code.wrap = "soft"
Else
Code.wrap = "off"
End If
strClass = ""
For Each objOption In WMIClasses.Options
If objOption.Selected = True Then
strClass = Trim( objOption.Text )
End If
Next
If strClass = "" Then
ButtonState
Exit Sub
End If
i = 0
For Each objOption in Properties.options
If Trim( objOption.Text ) <> "" Then
i = i + 1
End If
Next
If i = 0 Then
ButtonState
Exit Sub
End If
' Change mouse pointer to hourglass while running the code
Document.Body.Style.Cursor = "wait"
Code.Value = " . . . Please Wait . . ."
CodeLabel.InnerHTML = "Result:"
On Error Resume Next
Set objWMIService = GetObject( "winmgmts://./" & gvsNameSpace )
Set colItems = objWMIService.InstancesOf( strClass )
If colItems.Count = 1 Then
strCode = "1 instance:"
Else
strCode = colItems.Count & " instances:"
End If
strCode = strCode & vbCrLf & vbCrLf
maxLen = 0
For Each objItem In colItems
For Each objProperty In objItem.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
Next
For Each objItem In colItems
For Each objProperty In objItem.Properties_
strProperty = objProperty.Name
strCode = strCode & CreateLine( strProperty, maxLen ) & " "
If IsArray( objItem.Properties_.Item( strProperty, 0 ) ) Then
strCode = strCode & Join( objItem.Properties_.Item( strProperty, 0 ), ";" )
Else
strCode = strCode & objItem.Properties_.Item( strProperty, 0 )
End If
strCode = strCode & vbCrLf
Next
strCode = strCode & vbCrLf
Next
On Error Goto 0
Code.Value = strCode
Code.title = "After pressing the 'Generate Code' button again, the generated code to display the available properties and their values for the selected WMI class and scripting language will be shown here once more"
ButtonState
' Change mouse pointer back to default
Document.Body.Style.Cursor = "default"
End Sub
Sub ShowCode( )
Dim i, objOption, strClass
' Change mouse pointer to hourglass while running the code
Document.Body.Style.Cursor = "wait"
Codelabel.innerHTML = "Code:"
' Set word wrap
If gvbWordWrap Then
Code.wrap = "soft"
Else
Code.wrap = "off"
End If
strClass = ""
For Each objOption In WMIClasses.Options
If objOption.Selected = True Then
strClass = Trim( objOption.Text )
End If
Next
If strClass = "" Then
ButtonState
Exit Sub
End If
i = 0
For Each objOption in Properties.options
If Trim( objOption.Text ) <> "" Then
i = i + 1
End If
Next
If i = 0 Then
ButtonState
Exit Sub
End If
Select Case CodeLanguage.Value
Case "Batch"
ShowBatchCode strClass
Case "C#"
ShowCSharpCode strClass
Case "F#"
ShowFSharpCode strClass
Case "Java"
ShowJavaCode strClass
Case "JScript"
ShowJScriptCode strClass
Case "KiXtart"
ShowKiXtartCode strClass
Case "ObjectRexx"
ShowObjectRexxCode strClass
Case "Perl"
ShowPerlCode strClass
Case "PowerShell"
ShowPowerShellCode strClass
Case "Python"
ShowPythonCode strClass
Case "Ruby"
ShowRubyCode strClass
Case "VB.NET"
ShowVBDotNETCode strClass
Case "VBScript"
ShowVBScriptCode strClass
End Select
' Change mouse pointer back to default
Document.Body.Style.Cursor = "default"
Code.title = "After pressing the 'Run WMI Code' button, the generated (VBScript) code will be executed, and the result will be shown here"
End Sub
Sub ShowBatchCode( myClass )
Dim strCode
strCode = "@ECHO OFF" _
& vbCrLf _
& ":: WMI query to list all properties and values of the \\" & Replace( gvsNameSpace, "/", "\" ) & ":" & myClass & " class." _
& vbCrLf _
& ":: This batch file was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& ":: http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "IF ""%~1""=="""" (" _
& vbCrLf _
& vbTab & "SET Node=%ComputerName%" _
& vbCrLf _
& ") ELSE (" _
& vbCrLf _
& vbTab & "SET Node=%~1" _
& vbCrLf _
& ")" _
& vbCrLf & vbCrLf
If UCase( gvsNameSpace ) = "ROOT/CIMV2" Then
strCode = strCode _
& "FOR /F %%A IN ('WMIC.EXE /Node:""%Node%"" /Output:STDOUT Path " & myClass & " Get /Format:CSV ˆ| MORE /E +2 ˆ| FIND /C "",""') DO (" _
& vbCrLf _
& vbTab & "IF %%A EQU 1 (" _
& vbCrLf _
& vbTab & vbTab & "ECHO 1 instance:" _
& vbCrLf _
& vbTab & ") ELSE (" _
& vbCrLf _
& vbTab & vbTab & "ECHO %%A instances:" _
& vbCrLf _
& vbTab & ")" _
& vbCrLf _
& ")" _
& vbCrLf & vbCrLf _
& "WMIC.EXE /Node:""%Node%"" /Output:STDOUT Path " & myClass & " Get /Format:LIST" _
& vbCrLf
Else
strCode = strCode _
& "FOR /F %%A IN ('WMIC.EXE /Node:""%Node%"" /NameSpace:\\" & Replace( gvsNameSpace, "/", "\" ) & " /Output:STDOUT Path " & myClass & " Get /Format:CSV ˆ| MORE /E +2 ˆ| FIND /C "",""') DO (" _
& vbCrLf _
& vbTab & "IF %%A EQU 1 (" _
& vbCrLf _
& vbTab & vbTab & "ECHO 1 instance:" _
& vbCrLf _
& vbTab & ") ELSE (" _
& vbCrLf _
& vbTab & vbTab & "ECHO %%A instances:" _
& vbCrLf _
& vbTab & ")" _
& vbCrLf _
& ")" _
& vbCrLf & vbCrLf _
& "WMIC.EXE /Node:""%Node%"" /NameSpace:\\" & Replace( gvsNameSpace, "/", "\" ) & " /Output:STDOUT Path " & myClass & " Get /Format:LIST" & vbCrLf
End If
Code.Value = strCode
ButtonState
End Sub
Sub ShowCSharpCode( myClass )
Dim intCIMType, maxLen
Dim objClass, objProperty, objWMIService
Dim strCIMType, strCode
Const wbemCIMTypeSint16 = 2 'Signed 16-bit integer
Const wbemCIMTypeSint32 = 3 'Signed 32-bit integer
Const wbemCIMTypeReal32 = 4 '32-bit real number
Const wbemCIMTypeReal64 = 5 '64-bit real number
Const wbemCIMTypeString = 8 'String
Const wbemCIMTypeBoolean = 11 'Boolean value
Const wbemCIMTypeObject = 13 'CIM object
Const wbemCIMTypeSint8 = 16 'Signed 8-bit integer
Const wbemCIMTypeUint8 = 17 'Unsigned 8-bit integer
Const wbemCIMTypeUint16 = 18 'Unsigned 16-bit integer
Const wbemCIMTypeUint32 = 19 'Unsigned 32-bit integer
Const wbemCIMTypeSint64 = 20 'Signed 64-bit integer
Const wbemCIMTypeUint64 = 21 'Unsigned 64-bit integer
Const wbemCIMTypeDatetime = 101 'Date/time value
Const wbemCIMTypeReference = 102 'Reference to a CIM object
Const wbemCIMTypeChar16 = 103 '16-bit character
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "// WMI query to list all properties and values of the " & Replace( gvsNameSpace, "/", "\" ) & ":" & myClass & " class." _
& vbCrLf _
& "// This C# code was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "// http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "using System;" _
& vbCrLf _
& "using System.Linq;" _
& vbCrLf _
& "using System.Management;" _
& vbCrLf & vbCrLf _
& "namespace WMIGen" _
& vbCrLf _
& "{" _
& vbCrLf _
& vbTab & "public class " & myClass & "_Query" _
& vbCrLf _
& vbTab & "{" _
& vbCrLf _
& vbTab & vbTab & "public static int Main(string[] args)" _
& vbCrLf _
& vbTab & vbTab & "{" _
& vbCrLf _
& vbTab & vbTab & vbTab & "try" _
& vbCrLf _
& vbTab & vbTab & vbTab & "{" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "string computer = string.Empty;" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "if (args.Count() == 1)" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "{" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbtab & "computer = @""\\"" + args[0] + @""\"";" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "}" _
& vbCrLf & vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "ManagementObjectSearcher searcher = new ManagementObjectSearcher(computer + @""" & Replace( gvsNameSpace, "/", "\" ) & """, ""SELECT * FROM " & myClass & """);" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "ManagementObjectCollection colItems = searcher.Get( );" _
& vbCrLf & vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Console.WriteLine( ""{0} instance{1}"", colItems.Count, ( colItems.Count == 1 ? String.Empty : ""s"" ) );" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Console.WriteLine( );" _
& vbCrLf & vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "foreach ( ManagementObject queryObj in colItems )" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "{" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode & vbTab & vbTab & vbTab & vbTab & vbTab
If objProperty.IsArray = True Then
intCIMType = objProperty.CIMType
strCIMType = "string"
If intCIMType < 8 Then strCIMType = "UInt16"
If intCIMType > 15 And intCIMType < 100 Then strCIMType = "UInt16"
strCode = strCode & "if (queryObj[""" & objProperty.Name & """] == null)" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "{" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Console.WriteLine(""" & CreateLine( objProperty.Name, maxLen ) & " {0}"", queryObj[""" & objProperty.Name & """]);" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "}" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "else" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "{" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & strCIMType & "[] arrProperty = (" & strCIMType & "[])(queryObj[""" & objProperty.Name & """]);" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Console.Write(""" & CreateLine( objProperty.Name, maxLen ) & " "");" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Console.WriteLine(string.Join("";"", arrProperty.Select(cap => cap.ToString()).ToArray()));" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "}" _
& vbCrLf
Else
strCode = strCode & "Console.WriteLine(""" & CreateLine( objProperty.Name, maxLen ) & " {0}"", queryObj[""" & objProperty.Name & """]);" & vbCrLf
End If
Next
strCode = strCode & vbTab & vbTab & vbTab & vbTab & vbTab & "Console.WriteLine();" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "}" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "return 0;" _
& vbCrLf _
& vbTab & vbTab & vbTab & "}" _
& vbCrLf _
& vbTab & vbTab & vbTab & "catch (Exception e)" _
& vbCrLf _
& vbTab & vbTab & vbTab & "{" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Console.Error.WriteLine(""An error occurred while querying WMI: {0}"", e.Message);" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "return 1;" _
& vbCrLf _
& vbTab & vbTab & vbTab & "}" _
& vbCrLf _
& vbTab & vbTab & "}" _
& vbCrLf _
& vbTab & "}" _
& vbCrLf _
& "}" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowFSharpCode( myClass )
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "// WMI query to list all properties and values of the " & Replace( gvsNameSpace, "/", "\" ) & ":" & myClass & " class." _
& vbCrLf _
& "// This F# code was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "// http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "#if INTERACTIVE" _
& vbCrLf _
& "#r ""System""" _
& vbCrLf _
& "#r ""System.Management""" _
& vbCrLf _
& "#endif" _
& vbCrLf & vbCrLf _
& "open System" _
& vbCrLf _
& "open System.Management" _
& vbCrLf & vbCrLf _
& "let scope = ManagementScope(@""\\localhost\" & Replace( gvsNameSpace, "/", "\" ) & """)" _
& vbCrLf _
& "let query = ObjectQuery(""SELECT * FROM " & myClass & """)" _
& vbCrLf _
& "let searcher = new ManagementObjectSearcher(query)" _
& vbCrLf _
& "let colItems = searcher.Get( )" _
& vbCrLf & vbCrLf _
& "printfn ""%A instance(s)"" (colItems.Count)" _
& vbCrLf _
& "printfn """"" _
& vbCrLf & vbCrLf _
& "for obj in colItems do" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode & " printfn """ & CreateLine( objProperty.Name, maxLen ) & " %A"" (obj.GetPropertyValue(""" & objProperty.Name & """))" & vbCrLf
Next
strCode = strCode & " printfn """""
Code.Value = strCode
ButtonState
End Sub
Sub ShowJavaCode( myClass )
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "/**" _
& vbCrLf _
& " * WMI query to list all properties and values of the \\" & Replace( gvsNameSpace, "/", "\" ) & ":" & myClass & " class." _
& vbCrLf _
& " * Based on a JACOB sample by 'NickDMax' on DreamInCode.net:" _
& vbCrLf _
& " * http://www.dreamincode.net/code/snippet3297.htm" _
& vbCrLf _
& " * This Java code requires JACOB (JAva COm Bridge):" _
& vbCrLf _
& " * http://sourceforge.net/projects/jacob-project/" _
& vbCrLf _
& " * This Java code was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& " * http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf _
& " */" _
& vbCrLf & vbCrLf _
& "import com.jacob.activeX.ActiveXComponent;" _
& vbCrLf _
& "import com.jacob.com.Dispatch;" _
& vbCrLf _
& "import com.jacob.com.EnumVariant;" _
& vbCrLf _
& "import com.jacob.com.Variant;" _
& vbCrLf & vbCrLf _
& "public class WMIGen_" & myClass & " {" _
& vbCrLf _
& vbTab & "/**" _
& vbCrLf _
& vbTab & " * @param args" _
& vbCrLf _
& vbTab & " */" _
& vbCrLf _
& vbTab & "public static void main(String[] args) {" _
& vbCrLf _
& vbTab & vbTab & "String host = ""localhost"";" _
& vbCrLf _
& vbTab & vbTab & "if (args.length > 0) {" _
& vbCrLf _
& vbTab & vbTab & vbTab & "host = args[0];" _
& vbCrLf _
& vbTab & vbTab & "}" _
& vbCrLf _
& vbTab & vbTab & "String connectStr = String.format(""winmgmts:\\\\%s\\" & Replace( gvsNameSpace, "/", "\\" ) & """, host);" _
& vbCrLf _
& vbTab & vbTab & "String query = ""SELECT * FROM " & myClass & """;" _
& vbCrLf _
& vbTab & vbTab & "String property = """";" _
& vbCrLf _
& vbTab & vbTab & "ActiveXComponent axWMI = new ActiveXComponent(connectStr);" _
& vbCrLf _
& vbTab & vbTab & "Variant vCollection = axWMI.invoke(""ExecQuery"", new Variant(query));" _
& vbCrLf _
& vbTab & vbTab & "EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch());" _
& vbCrLf _
& vbTab & vbTab & "Dispatch item = null;" _
& vbCrLf _
& vbTab & vbTab & "while (enumVariant.hasMoreElements()) {" _
& vbCrLf _
& vbTab & vbTab & vbTab & "item = enumVariant.nextElement().toDispatch();" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode _
& vbTab & vbTab & vbTab & "property = Dispatch.call(item,""" & objProperty.Name & """).toString();" _
& vbCrLf _
& vbTab & vbTab & vbtab & "System.out.printf(""" & createline( objProperty.Name, maxlen ) & " %s\n"",property);" _
& vbCrLf
Next
strCode = strCode _
& vbTab & vbTab & vbTab & "System.out.printf(""\n"");" _
& vbCrLf _
& vbTab & vbTab & "}" _
& vbCrLf _
& vbTab & "}" _
& vbCrLf _
& "}" _
& vbCrLf
Code.value = strCode
ButtonState
End Sub
Sub ShowJScriptCode( myClass )
' IsArray and Join() functionality "borrowed" from Scriptomatic 2.0
' http://www.microsoft.com/downloads/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178&DisplayLang=en
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "// WMI query to list all properties and values of the " & gvsNameSpace & ":" & myClass & " class." _
& vbCrLf _
& "// This JScript code was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "// http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "var wbemFlagReturnImmediately = 0x10;" _
& vbCrLf _
& "var wbemFlagForwardOnly = 0x20;" _
& vbCrLf & vbCrLf
End If
strCode = strCode _
& "objArgs = WScript.Arguments;" _
& vbCrLf _
& "if ( objArgs.length == 1 ) {" _
& vbCrLf _
& vbtab & "var strComputer = objArgs[0]" _
& vbCrLf _
& "} else {" _
& vbCrLf _
& vbtab & "var strComputer = "".""" _
& vbCrLf _
& "}" _
& vbCrLf & vbCrLf _
& "var objWMIService = GetObject( ""winmgmts://"" + strComputer + ""/" & gvsNameSpace & """ );" _
& vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "var colItems = objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """, ""WQL"", wbemFlagReturnImmediately | wbemFlagForwardOnly );"
Else
strCode = strCode _
& "var colItems = objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """ );" _
& vbCrLf & vbCrLf _
& "if ( colItems.Count == 1 ) {" _
& vbCrLf _
& vbTab & "WScript.Echo( ""1 instance:"" );" _
& vbCrLf _
& "} else {" _
& vbCrLf _
& vbTab & "WScript.Echo( colItems.Count + "" instances:"" );" _
& vbCrLf _
& "}" _
& vbCrLf _
& "WScript.Echo( );"
End If
strCode = strCode _
& vbCrLf & vbCrLf _
& "var enumItems = new Enumerator( colItems );" _
& vbCrLf _
& "for ( ; !enumItems.atEnd(); enumItems.moveNext( ) ) {" _
& vbCrLf _
& vbtab & "var objItem = enumItems.item( );" _
& vbCrLf & vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
If objProperty.IsArray = True Then
strCode = strCode & vbTab & "try { WScript.Echo( """ & CreateLine( objProperty.Name, maxLen ) & " "" + ( objItem." & objProperty.Name & ".toArray( ) ).join( "","" ) ); }" _
& vbCrLf _
& vbTab & "catch( e ) { WScript.Echo( """ & CreateLine( objProperty.Name, maxLen ) & " null"" ); }" _
& vbCrLf
Else
strCode = strCode & vbTab & "WScript.Echo( """ & CreateLine( objProperty.Name, maxLen ) & " "" + objItem." & objProperty.Name & " );" _
& vbCrLf
End If
Next
strCode = strCode _
& vbTab & "WScript.Echo( """" );" _
& vbCrLf & "}" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowKiXtartCode( myClass )
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "; WMI query to list all properties and values of the " & gvsNameSpace & ":" & myClass & " class." _
& vbCrLf _
& "; This KiXtart script was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "; http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "$wbemFlagReturnImmediately = &10" _
& vbCrLf _
& "$wbemFlagForwardOnly = &20" _
& vbCrLf & vbCrLf
End If
strCode = strCode _
& "Break On" _
& vbCrLf & vbCrLf _
& "If $computer = """"" _
& vbCrLf _
& vbTab & "$arrKixVer = Split( @Kix, ""."" )" _
& vbCrLf _
& vbTab & "$KiXVer = 100 * $arrKixVer[ 0 ] + $arrKixVer[ 1 ]" _
& vbCrLf _
& vbTab & "$computer = "".""" _
& vbCrLf _
& vbTab & "If $KixVer > 451" _
& vbCrLf _
& vbTab & vbTab & "$arrGetCommandLine = GetCommandLine( 1 )" _
& vbCrLf _
& vbTab & vbTab & "$LastArg = $arrGetCommandLine[ UBound( $arrGetCommandLine ) ]" _
& vbCrLf _
& vbTab & vbTab & "If $LastArg <> ""@ScriptDir\@ScriptName""" _
& vbCrLf _
& vbTab & vbTab & vbTab & "$computer = $LastArg" _
& vbCrLf _
& vbTab & vbTab & "EndIf" _
& vbCrLf _
& vbTab & "EndIf" _
& vbCrLf _
& "EndIf" _
& vbCrLf & vbCrLf _
& "$objWMIService = GetObject( ""winmgmts://"" + $computer + ""/" & gvsNameSpace & """ )" _
& vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "$colItems = $objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """, ""WQL"", wbemFlagReturnImmediately + wbemFlagForwardOnly )"
Else
strCode = strCode _
& "$colItems = $objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """ )" _
& vbCrLf & vbCrLf _
& "If $colItems.Count = 1" _
& vbCrLf _
& vbTab & "? ""1 instance:"" ?" _
& vbCrLf _
& "Else" _
& vbCrLf _
& vbTab & "? """" + $colItems.Count + "" instances:"" ?" _
& vbCrLf _
& "EndIf"
End If
strCode = strCode _
& vbCrLf & vbCrLf _
& "For Each $objItem In $colItems" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode & vbTab & "? """ & CreateLine( objProperty.Name, maxLen ) & " "" + "
If objProperty.IsArray = True Then strCode = strCode & "Join( "
strCode = strCode & "$objItem." & objProperty.Name
If objProperty.IsArray = True Then strCode = strCode & ", "","" )"
strCode = strCode & vbCrLf
Next
strCode = strCode _
& vbTab & "?" _
& vbCrLf _
& "Next" _
& vbCrLf & vbCrLf _
& "Quit" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowObjectRexxCode( myClass )
' Based on the Rexx script samples found at the Script Repository:
' http://www.microsoft.com/technet/scriptcenter/scripts/rexx/default.mspx?mfr=true
' Tested with Open Object Rexx: http://www.oorexx.org/
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "/*" _
& vbCrLf _
& "WMI query to list all properties and values of the " & gvsNameSpace & ":" & myClass & " class." _
& vbCrLf _
& "This Open Object Rexx script was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf _
& "*/" _
& vbCrLf & vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "wbemFlagReturnImmediately = 16" _
& vbCrLf _
& "wbemFlagForwardOnly = 32" _
& vbCrLf & vbCrLf
End If
strCode = strCode _
& "Parse Upper Arg strComputer ." _
& vbCrLf _
& "If strComputer = """" Then strComputer = "".""" _
& vbCrLf & vbCrLf _
& "objWMIService = .OLEObject~GetObject( ""winmgmts://""||strComputer||""/" & gvsNameSpace & """ )" _
& vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "colItems = objWMIService~ExecQuery( ""SELECT * FROM " & myClass & """, ""WQL"", wbemFlagReturnImmediately + wbemFlagForwardOnly );"
Else
strCode = strCode _
& "colItems = objWMIService~ExecQuery( ""SELECT * FROM " & myClass & """ )" _
& vbCrLf & vbCrLf _
& "If colItems~Count = 1 Then" _
& vbCrLf _
& vbtab & "Say ""1 instance:""" _
& vbCrLf _
& "Else" _
& vbCrLf _
& vbTab & "Say colItems~Count||"" instances:""" _
& vbCrLf & vbCrLf _
& "Say"
End If
strCode = strCode _
& vbCrLf & vbCrLf _
& "Do objItem Over colItems" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
If objProperty.IsArray = True Then
strCode = strCode _
& vbTab & "str" & objProperty.Name & " = """"" _
& vbCrLf _
& vbTab & "If objItem~" & objProperty.Name & " <> .NIL Then" _
& vbCrLf _
& vbTab & vbTab & "Do i = 1 To Length(objItem~" & objProperty.Name & ")" _
& vbCrLf _
& vbTab & vbTab & vbTab & "If objItem~" & objProperty.Name & "[i] <> .NIL Then" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "str" & objProperty.Name & " = str" & objProperty.Name & "||"",""||objItem~" & objProperty.Name & "[i]" _
& vbCrLf _
& vbTab & vbTab & "End" _
& vbCrLf _
& vbTab & "If Length( str" & objProperty.Name & ") > 1 Then" _
& vbCrLf _
& vbTab & vbTab & vbTab & "str" & objProperty.Name & " = str" & objProperty.Name & "~substr(2,)" _
& vbCrLf _
& vbTab & "Say """ & CreateLine( objProperty.Name, maxLen ) & " ""||str" & objProperty.Name
Else
strCode = strCode _
& vbTab & "If objItem~" & objProperty.Name & " = .NIL Then" _
& vbCrLf _
& vbTab & vbTab & "str" & objProperty.Name & " = """"" _
& vbCrLf _
& vbTab & "Else" _
& vbCrLf _
& vbTab & vbTab & "str" & objProperty.Name & " = objItem~" & objProperty.Name _
& vbCrLf _
& vbTab & "Say """ & CreateLine( objProperty.Name, maxLen ) & " ""||str" & objProperty.Name
End If
strCode = strCode & vbCrLf
Next
strCode = strCode _
& vbTab & "Say" _
& vbCrLf _
& "End" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowPerlCode( myClass )
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "#! perl" _
& vbCrLf & vbCrLf _
& "# WMI query to list all properties and values of the " & gvsNameSpace & ":" & myClass & " class." _
& vbCrLf _
& "# This Perl script was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "# http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "use Win32::OLE( 'in' );" _
& vbCrLf & vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "use constant wbemFlagReturnImmediately => 0x10;" _
& vbCrLf _
& "use constant wbemFlagForwardOnly => 0x20;" _
& vbCrLf & vbCrLf
End If
strCode = strCode _
& "if ( $ARGV[0] ) {" _
& vbCrLf _
& vbTab & "$computer = $ARGV[0];" _
& vbCrLf _
& "} else {" _
& vbCrLf _
& vbTab & "$computer = ""."";" _
& vbCrLf _
& "}" _
& vbCrLf & vbCrLf _
& "my $objWMIService = Win32::OLE->GetObject( ""winmgmts://$computer/" & gvsNameSpace & """ ) or die ""WMI connection failed.\n"";" _
& vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "my $colItems = $objWMIService->ExecQuery( ""SELECT * FROM " & myClass & """, ""WQL"", wbemFlagReturnImmediately | wbemFlagForwardOnly );"
Else
strCode = strCode _
& "my $colItems = $objWMIService->ExecQuery( ""SELECT * FROM " & myClass & """ );" _
& vbCrLf _
& "if ( $colItems->Count == 1 ) {" _
& vbCrLf _
& vbTab & "print ""1 instance:\n"";" _
& vbCrLf _
& "} else {" _
& vbCrLf _
& vbTab & "printf( ""%s instances:\n\n"", $colItems->Count );" _
& vbCrLf _
& "}" _
& vbCrLf & vbCrLf _
End If
strCode = strCode _
& vbCrLf & vbCrLf _
& "foreach my $objItem ( in $colItems ) {" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode & vbTab & "print """ & CreateLine( objProperty.Name, maxLen ) & " "" . "
If objProperty.IsArray = True Then
strCode = strCode & "join( "","", ( in $objItem->{ " & objProperty.Name & " } ) )"
Else
strCode = strCode & "$objItem->{ " & objProperty.Name & " }"
End If
strCode = strCode & " . ""\n"";" & vbCrLf
Next
strCode = strCode _
& vbTab & "print ""\n"";" _
& vbCrLf _
& "}" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowPowerShellCode( myClass )
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "# WMI query to list all properties and values of the \\" & Replace( gvsNameSpace, "/", "\" ) & ":" & myClass & " class." _
& vbCrLf _
& "# This PowerShell script was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "# http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "param( [string]$strComputer = ""."" )" _
& vbCrLf & vbCrLf _
& "$colItems = get-wmiobject -class """ & myClass & """ -namespace """ & Replace( gvsNameSpace, "/", "\" ) & """ -computername $strComputer" _
& vbCrLf & vbCrLf _
& "$instances = ($colItems | measure-object).Count" _
& vbCrLf _
& "if ($instances -eq 1) {" _
& vbCrLf _
& vbTab & "write-host ""1 instance:""" _
& vbCrLf _
& "} else {" _
& vbCrLf _
& vbTab & "write-host ""$instances instances:""" _
& vbCrLf _
& "}" _
& vbCrLf _
& "write-host" _
& vbCrLf & vbCrLf _
& "foreach ($objItem in $colItems) {" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode & vbTab & "write-host """ & CreateLine( objProperty.Name, maxLen ) & """ $objItem." & objProperty.Name & vbCrLf
Next
strCode = strCode _
& vbTab & "write-host" _
& vbCrLf _
& "}" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowPythonCode( myClass )
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "#! python" _
& vbCrLf & vbCrLf _
& "# WMI query to list all properties and values of the " & gvsNameSpace & ":" & myClass & " class." _
& vbCrLf _
& "# To use WMI in Python, install the Python for Windows extensions:" _
& vbCrLf _
& "# http://sourceforge.net/projects/pywin32/files/pywin32/" _
& vbCrLf _
& "# This Python script was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "# http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "import sys" _
& vbCrLf _
& "import win32com.client" _
& vbCrLf & vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "wbemFlagReturnImmediately = 0x10" _
& vbCrLf _
& "wbemFlagForwardOnly = 0x20" _
& vbCrLf & vbCrLf
End If
strCode = strCode _
& "try:" _
& vbCrLf _
& vbTab & "strComputer = sys.argv[1]" _
& vbCrLf _
& "except IndexError:" _
& vbCrLf _
& vbTab & "strComputer = "".""" _
& vbCrLf & vbCrLf _
& "objWMIService = win32com.client.Dispatch( ""WbemScripting.SWbemLocator"" )" _
& vbCrLf _
& "objSWbemServices = objWMIService.ConnectServer( strComputer, """ & gvsNameSpace & """ )" _
& vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "colItems = objSWbemServices.ExecQuery( ""SELECT * FROM " & myClass & """, ""WQL"", wbemFlagReturnImmediately + wbemFlagForwardOnly )"
Else
strCode = strCode _
& "colItems = objSWbemServices.ExecQuery( ""SELECT * FROM " & myClass & """ )" _
& vbCrLf & vbCrLf _
& "if colItems.Count == 1:" _
& vbCrLf _
& vbTab & "print( ""1 instance:"" )" _
& vbCrLf _
& "else:" _
& vbCrLf _
& vbTab & "print( str( colItems.Count ) + "" instances:"" )" _
& vbCrLf _
& "print( )"
End If
strCode = strCode _
& vbCrLf & vbCrLf _
& "for objItem in colItems:" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
If objProperty.IsArray = True Then
strCode = strCode & vbTab & "strList = "" """ _
& vbCrLf _
& vbTab & "try:" _
& vbCrLf _
& vbTab & vbTab & "for objElem in objItem." & objProperty.Name & " :" _
& vbCrLf _
& vbTab & vbTab & vbTab & "strList = strList + str( objElem ) + "",""" _
& vbCrLf _
& vbTab & "except:" _
& vbCrLf _
& vbTab & vbTab & "strList = strList + 'null'" _
& vbCrLf _
& vbTab & "print( """ & CreateLine( objProperty.Name, maxLen ) & """ + strList )" _
& vbCrLf
Else
strCode = strCode _
& vbTab & "if objItem." & objProperty.Name & " != None:" _
& vbCrLf _
& vbTab & vbTab & "print( """ & CreateLine( objProperty.Name, maxLen ) & " "" + str( objItem." & objProperty.Name & " ) )" _
& vbCrLf
End If
Next
strCode = strCode & vbTab & "print( )" & vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowRubyCode( myClass )
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "# WMI query to list all properties and values of the " & gvsNameSpace & ":" & myClass & " class." _
& vbCrLf _
& "# This Ruby script was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "# http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "require 'win32ole'" _
& vbCrLf & vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "wbemFlagReturnImmediately = 0x10" _
& vbCrLf _
& "wbemFlagForwardOnly = 0x20" _
& vbCrLf & vbCrLf
End If
strCode = strCode _
& "if ARGV[0]" _
& vbCrLf _
& vbTab & "computer = ARGV[0]" _
& vbCrLf _
& "else" _
& vbCrLf _
& vbTab & "computer = "".""" _
& vbCrLf _
& "end" _
& vbCrLf & vbCrLf _
& "objWMIService = WIN32OLE.connect( ""winmgmts://#{computer}/" & gvsNameSpace & """ )" _
& vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "colItems = objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """, ""WQL"", wbemFlagReturnImmediately + wbemFlagForwardOnly )"
Else
strCode = strCode _
& "colItems = objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """ )" _
& vbCrLf & vbCrLf _
& "if colItems.Count == 1" _
& vbCrLf _
& vbTab & "puts ""1 instance:""" _
& vbCrLf _
& "else" _
& vbCrLf _
& vbTab & "puts ""#{colItems.Count} instances:""" _
& vbCrLf _
& "end" _
& vbCrLf _
& "puts"
End If
strCode = strCode _
& vbCrLf & vbCrLf _
& "for objItem in colItems do" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode & vbTab & "puts """ & CreateLine( objProperty.Name, maxLen ) & " #{objItem." & objProperty.Name & "}""" & vbCrLf
Next
strCode = strCode _
& vbTab & "puts" _
& vbCrLf _
& "end" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowVBDotNETCode( myClass )
Dim intCIMType, maxLen, objClass, objProperty, objWMIService, strArrayPr, strCIMType, strCode
Const wbemCIMTypeSint16 = 2 'Signed 16-bit integer
Const wbemCIMTypeSint32 = 3 'Signed 32-bit integer
Const wbemCIMTypeReal32 = 4 '32-bit real number
Const wbemCIMTypeReal64 = 5 '64-bit real number
Const wbemCIMTypeString = 8 'String
Const wbemCIMTypeBoolean = 11 'Boolean value
Const wbemCIMTypeObject = 13 'CIM object
Const wbemCIMTypeSint8 = 16 'Signed 8-bit integer
Const wbemCIMTypeUint8 = 17 'Unsigned 8-bit integer
Const wbemCIMTypeUint16 = 18 'Unsigned 16-bit integer
Const wbemCIMTypeUint32 = 19 'Unsigned 32-bit integer
Const wbemCIMTypeSint64 = 20 'Signed 64-bit integer
Const wbemCIMTypeUint64 = 21 'Unsigned 64-bit integer
Const wbemCIMTypeDatetime = 101 'Date/time value
Const wbemCIMTypeReference = 102 'Reference to a CIM object
Const wbemCIMTypeChar16 = 103 '16-bit character
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "' WMI query to list all properties and values of the \\" & Replace( gvsNameSpace, "/", "\" ) & ":" & myClass & " class." _
& vbCrLf _
& "' This VB .NET code was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "' http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf _
& "Imports System" _
& vbCrLf _
& "Imports System.Management" _
& vbCrLf & vbCrLf _
& "Namespace WMIGen" _
& vbCrLf _
& vbTab & "Module " & myClass & "_Query" _
& vbCrLf _
& vbTab & vbTab & "Sub Main(ByVal ParamArray args() As String)" _
& vbCrLf _
& vbTab & vbTab & vbTab & "Dim computer As String = String.Empty" _
& vbCrLf _
& vbTab & vbTab & vbTab & "Try" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "If args.Length > 0 Then" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbtab & "computer = ""\\"" & args(0) & ""\""" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "End If" _
& vbCrLf & vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Dim searcher As New ManagementObjectSearcher(computer & """ & Replace( gvsNameSpace, "/", "\" ) & """, ""SELECT * FROM " & myClass & """)" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Dim colItems = searcher.Get()" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Dim arrPropertyInt() As UInt16" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Dim arrPropertyStr() As String" _
& vbCrLf & vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "If colItems.Count = 1 Then" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "Console.WriteLine(""1 instance:"")" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Else" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "Console.WriteLine(""{0} instances:"", colItems.Count)" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "End If" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Console.WriteLine()" _
& vbCrLf & vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "For Each queryObj As ManagementObject In colItems" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
strCode = strCode & vbTab & vbTab & vbTab & vbTab & vbTab
If objProperty.IsArray = True Then
intCIMType = objProperty.CIMType
strCIMType = "String"
strArrayPr = "arrPropertyStr"
If intCIMType < 8 Then strCIMType = "UInt16"
If intCIMType > 15 And intCIMType < 100 Then strCIMType = "UInt16"
If strCIMType = "UInt16" Then strArrayPr = "arrPropertyInt"
strCode = strCode _
& "If queryObj(""" & objProperty.Name & """) Is Nothing Then" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Console.WriteLine(""" & CreateLine( objProperty.Name, maxLen ) & " {0}"", queryObj(""" & objProperty.Name & """))" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "Else" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & strArrayPr & " = queryObj(""" & objProperty.Name & """)" _
& vbCrLf
If strCIMType = "UInt16" Then
strCode = strCode _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "ReDim arrPropertyStr(UBound(arrPropertyInt))" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "For i = 0 To UBound(arrPropertyInt)" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "arrPropertyStr(i) = CStr(arrPropertyInt(i))" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Next" _
& vbCrLf
End If
strCode = strCode _
& vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "Console.WriteLine(""" & CreateLine( objProperty.Name, maxLen ) & " {0}"", Join(arrPropertyStr, "";""))" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "End If" _
& vbCrLf
Else
strCode = strCode & "Console.WriteLine(""" & CreateLine( objProperty.Name, maxLen ) & " {0}"", queryObj(""" & objProperty.Name & """))" & vbCrLf
End If
Next
strCode = strCode _
& vbTab & vbTab & vbTab & vbTab & vbtab & "Console.WriteLine()" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Next" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Environment.Exit(0)" _
& vbCrLf _
& vbTab & vbTab & vbTab & "Catch err As ManagementException" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Console.Error.WriteLine(""An error occurred while querying WMI: "" & err.Message)" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Environment.Exit(1)" _
& vbCrLf _
& vbTab & vbTab & vbTab & "Catch err As System.Runtime.InteropServices.COMException" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Console.Error.Write(""An error occurred"")" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "If Not String.IsNullOrEmpty(computer) Then" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & vbTab & "Console.Error.Write("" while connecting to computer "" & computer.Replace(""\"", String.Empty))" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "End If" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Console.Error.WriteLine("": "" & err.Message)" _
& vbCrLf _
& vbTab & vbTab & vbTab & vbTab & "Environment.Exit(1)" _
& vbCrLf _
& vbTab & vbTab & vbTab & "End Try" _
& vbCrLf _
& vbTab & vbTab & "End Sub" _
& vbCrLf _
& vbTab & "End Module" _
& vbCrLf _
& "End Namespace" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Sub ShowVBScriptCode( myClass )
' IsArray an Join() functionality "borrowed" from Scriptomatic 2.0
' http://www.microsoft.com/downloads/details.aspx?FamilyID=09dfc342-648b-4119-b7eb-783b0f7d1178&DisplayLang=en
Dim maxLen, objClass, objProperty, objWMIService, strCode
Set objWMIService = GetObject( "winmgmts:{impersonationLevel=impersonate}" & gvsNameSpace )
Set objClass = objWMIService.Get( myClass )
strCode = "' WMI query to list all properties and values of the " & gvsNameSpace & ":" & myClass & " class." _
& vbCrLf _
& "' This VBScript code was generated using the WMI Code Generator, Version " & WMIGen.Version _
& vbCrLf _
& "' http://www.robvanderwoude.com/wmigen.php" _
& vbCrLf & vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "Const wbemFlagReturnImmediately = &h10" _
& vbCrLf _
& "Const wbemFlagForwardOnly = &h20" _
& vbCrLf & vbCrLf
End If
strCode = strCode _
& "On Error Resume Next" _
& vbCrLf & vbCrLf _
& "If WScript.Arguments.UnNamed.Count = 1 Then" _
& vbCrLf _
& vbTab & "strComputer = WScript.Arguments.UnNamed(1)" _
& vbCrLf _
& "Else" _
& vbCrLf _
& vbTab & "strComputer = "".""" _
& vbCrLf _
& "End If" _
& vbCrLf & vbCrLf _
& "Set objWMIService = GetObject( ""winmgmts://"" & strComputer & ""/" & gvsNameSpace & """ )" _
& vbCrLf
If gvbResourceFriendly Then
strCode = strCode _
& "Set colInstances = objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """, ""WQL"", wbemFlagReturnImmediately + wbemFlagForwardOnly )"
Else
strCode = strCode _
& "Set colInstances = objWMIService.ExecQuery( ""SELECT * FROM " & myClass & """ )" _
& vbCrLf & vbCrLf _
& "If colInstances.Count = 1 Then" _
& vbCrLf _
& vbTab & "WScript.Echo ""1 instance:"" & vbCrLf" _
& vbCrLf _
& "Else" _
& vbCrLf _
& vbTab & "WScript.Echo colInstances.Count & "" instances:"" & vbCrLf" _
& vbCrLf _
& "End If"
End if
strCode = strCode _
& vbCrLf & vbCrLf _
& "For Each objInstance In colInstances" _
& vbCrLf
maxLen = 0
For Each objProperty In objClass.Properties_
If Len( objProperty.Name ) > maxLen Then maxLen = Len( objProperty.Name )
Next
For Each objProperty In objClass.Properties_
If objProperty.IsArray = True Then
strCode = strCode _
& vbTab & "WScript.Echo """ & CreateLine( objProperty.Name, maxLen ) & " "" & Join( objInstance." & objProperty.Name & ", "","" )"
Else
strCode = strCode _
& vbTab & "WScript.Echo """ & CreateLine( objProperty.Name, maxLen ) & " "" & objInstance." & objProperty.Name
End If
strCode = strCode & vbCrLf
Next
strCode = strCode _
& vbTab & "WScript.Echo" _
& vbCrLf _
& "Next" _
& vbCrLf
Code.Value = strCode
ButtonState
End Sub
Function TextFromHTML( URL )
' Basic routine borrowed from http://dev.remotenetworktechnology.com/wsh/rubegoldberg.htm
' Improved wait-until-ready routine for HTAs by McKirahan on
' http://support.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.scripting.scriptlets&tid=be461ec2-b444-440c-8155-ad0e8e839ca6&lang=en&cr=US&sloc=en-us&p=1
Dim objIE
Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Navigate URL
While objIE.Busy
Wend
TextFromHTML = objIE.Document.Body.InnerText
objIE.Quit
Set objIE = Nothing
End Function
Sub ToggleSettings( )
If Settings.style.display = "none" Then
Settings.style.display = "block"
SettingsButton.value = "Hide Settings"
SettingsButton.title = "Press this button to hide the program's configuration"
If gvbShowPerfClasses Then
Exclude_Perf.checked = False
Else
Exclude_Perf.checked = True
End If
If gvbResourceFriendly Then
Resource_Friendly.checked = True
Else
Resource_Friendly.checked = False
End If
If gvbShowAllClasses Then
Win32_Only.checked = False
Else
Win32_Only.checked = True
End If
If gvbUseSpacesInProperties Then
Use_Spaces.checked = True
Else
Use_Spaces.checked = False
End If
If gvbWordWrap Then
Word_Wrap.checked = True
Else
Word_Wrap.checked = False
End If
Else
Settings.style.display = "none"
SettingsButton.value = "Configure"
SettingsButton.title = "Press this button to change the program's configuration"
End If
End Sub
Sub Window_Onload
Dim blnCheck, objOption, strCheckMsg
strCheckMsg = ""
AppVersion.InnerHTML = WMIGen.Version
document.title = "WMI Code Generator " & WMIGen.Version
ButtonState
If InStr( gvsCmdLine, "/NOPERF" ) Then gvbShowPerfClasses = False
If InStr( gvsCmdLine, "/RESOURCEFRIENDLY" ) Then gvbResourceFriendly = True
If InStr( gvsCmdLine, "/SPACES" ) Then gvbUseSpacesInProperties = True
If InStr( gvsCmdLine, "/WIN32" ) Then gvbShowAllClasses = False
If InStr( gvsCmdLine, "/WRAP" ) Then gvbWordWrap = True
If InStr( gvsCmdLine, "/CLASS:" ) Then
' Extract language from command line
gvsClass = Mid( gvsCmdLine, InStr( gvsCmdLine, "/CLASS:" ) + 7 )
If InStr( gvsClass, " " ) > 0 Then
gvsClass = Trim( Left( gvsClass, InStr( gvsClass, " " ) ) )
End If
' Remove doublequotes
If Left( gvsClass, 1 ) = """" Then
gvsClass = Mid( gvsClass, 2 )
End If
If Right( gvsClass, 1 ) = """" Then
gvsClass = Mid( gvsClass, 1, Len( gvsClass ) - 1 )
End If
' Remove whitespace
gvsClass = Trim( gvsClass )
End If
If InStr( gvsCmdLine, "/LANGUAGE:" ) Then
' Extract language from command line
gvsLanguage = Mid( gvsCmdLine, InStr( gvsCmdLine, "/LANGUAGE:" ) + 10 )
If InStr( gvsLanguage, " " ) > 0 Then
gvsLanguage = Trim( Left( gvsLanguage, InStr( gvsLanguage, " " ) ) )
End If
' Remove doublequotes
If Left( gvsLanguage, 1 ) = """" Then
gvsLanguage = Mid( gvsLanguage, 2 )
End If
If Right( gvsLanguage, 1 ) = """" Then
gvsLanguage = Mid( gvsLanguage, 1, Len( gvsLanguage ) - 1 )
End If
' Remove whitespace
gvsLanguage = Trim( gvsLanguage )
' Select the language of choice
blnCheck = False
For Each objOption In CodeLanguage.Options
If UCase( objOption.Value ) = gvsLanguage Then
objOption.Selected = True
blnCheck = True
End If
Next
If Not blnCheck Then
gvbCmdLineValidate = False
gvbLanguageValidate = False
End If
End If
If InStr( gvsCmdLine, "/NAMESPACE:" ) Then
' Extract namespace from command line
gvsNameSpace = Mid( gvsCmdLine, InStr( gvsCmdLine, "/NAMESPACE:" ) + 11 )
If InStr( gvsNameSpace, " " ) > 0 Then
gvsNameSpace = Trim( Left( gvsNameSpace, InStr( gvsNameSpace, " " ) ) )
End If
' Remove doublequotes
If Left( gvsNameSpace, 1 ) = """" Then
gvsNameSpace = Mid( gvsNameSpace, 2 )
End If
If Right( gvsNameSpace, 1 ) = """" Then
gvsNameSpace = Mid( gvsNameSpace, 1, Len( gvsNameSpace ) - 1 )
End If
' Remove whitespace
gvsNameSpace = Trim( gvsNameSpace )
' Format namespace with forward slashes
gvsNameSpace = Replace( gvsNameSpace, "\", "/" )
End If
If InStr( gvsCmdLine, "/FAST" ) And gvsNameSpace <> "" Then gvbFast = True
If InStr( gvsCmdLine, "/NOUPDCHK" ) Then
gvbUpdateCheck = False
Hide_Update.checked = True
End If
CheckWindowSize
FillNameSpacesDropDown
FillClassDropDown
If gvbCmdLineValidate Then
If InStr( gvsCmdLine, "/GENERATE" ) Then
ShowCode
If InStr( gvsCmdLine, "/COPY" ) Then
CopyCode
window.close
End If
Else
If InStr( gvsCmdLine, "/RUN" ) Then
RunCode
If InStr( gvsCmdLine, "/COPY" ) Then
CopyCode
Location.Unload( True )
End If
End If
End If
Else
strCheckMsg = ""
If Not gvbNameSpaceValidate Then
strCheckMsg = "Invalid namespace""" & gvsNameSpace & """" & vbCrLf
End If
If Not gvbClassValidate Then
strCheckMsg = strCheckMsg & "Invalid class name """ & gvsClass & vbCrLf
End If
If Not gvbLanguageValidate Then
strCheckMsg = strCheckMsg & "Invalid language """ & gvsLanguage & """" & vbCrLf
End If
MsgBox strCheckMsg, vbOKOnly, "Invalid arguments"
Location.Reload( True )
End If
CheckUpdate
CreateIEHelp
gvoIEHelp.Visible = 0
If InStr( gvsCmdLine, "?" ) Or InStr( gvsCmdLine, "HELP" ) Then HelpMsg
End Sub
Sub Window_Onunload
On Error Resume Next
' Close and release IE object
gvoIEHelp.Quit
Set gvoIEHelp = Nothing
On Error Goto 0
End Sub
Sub WindowSize( iWidth, iHeight )
On Error Resume Next
Dim posWidth, posHeight
posWidth = Max( 0, Int( ( window.screen.width - iWidth ) / 2 ) )
posHeight = Max( 0, Int( ( window.screen.height - iHeight ) / 2 ) )
window.resizeTo iWidth, iHeight
window.moveTo posWidth, posHeight
On Error GoTo 0
End Sub
Sub WxH( posColon )
Dim myHeight, myWidth, posSpace, posX
Dim strWxH
Const minHeight = 600
Const minWidth = 800
strWxH = Mid( gvsCmdLine, posColon + 1 )
posSpace = InStr( strWxH, " " )
If posSpace > 0 Then
strWxH = Left( strWxH, posSpace - 1 )
End If
posX = InStr( strWxH, "X" )
If posX > 0 Then
gviReqWidth = Int( Left( strWxH, posX - 1 ) )
gviReqHeight = Int( Mid( strWxH, posX + 1 ) )
If IsNumeric( gviReqHeight ) And IsNumeric( gviReqWidth ) Then
gviReqHeight = Max( gviReqHeight, minHeight )
gviReqWidth = Max( gviReqWidth, minWidth )
gviReqHeight = Min( gviReqHeight, Int( window.screen.height ) )
gviReqWidth = Min( gviReqWidth, Int( window.screen.width ) )
WindowSize gviReqWidth, gviReqHeight
End If
End If
End Sub
</script>
<body style="font:12 pt arial; color:white; filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#000000', EndColorStr='#FFFFFF')" onresize="CheckWindowSize()" onhelp="HelpMsg()">
<div align="Center">
<div id="Update" style="margin: 10px auto 10px auto; width: 750px; padding: 10px; display: none;"></div>
<table border="0" cellspacing="10">
<tr id="Settings" style="display: none;">
<th colspan="2" style="border: 1px solid white; padding: 25px;"><table style="width: 100%;">
<tr>
<td style="vertical-align: top;"><input type="checkbox" name="Win32_Only" id="Win32_Only" onclick="OnClickCheckboxWin32_Only"></td>
<td style="vertical-align: top; width: 32%;"><label for="Win32_Only">List Win32 classes only</label></td>
<td style="vertical-align: top;"><input type="checkbox" name="Word_Wrap" id="Word_Wrap" onclick="OnClickCheckboxWordWrap"></td>
<td style="vertical-align: top; width: 32%;"><label for="Word_Wrap">Enable (soft) word wrap in code screen</label></td>
<td style="vertical-align: top;" title="Applies to JScript, KiXtart, Object Rexx, Perl, Python, Ruby and VBScript code only"><input type="checkbox" name="Resource_Friendly" id="Resource_Friendly" onclick="OnClickCheckboxResourceFriendly"></td>
<td style="vertical-align: top; width: 32%;" title="Applies to JScript, KiXtart, Object Rexx, Perl, Python, Ruby and VBScript code only"><label for="Resource_Friendly">Generate resource-friendly code</label></td>
</tr>
<tr>
<td style="vertical-align: top;"><input type="checkbox" name="Exclude_Perf" id="Exclude_Perf" onclick="OnClickCheckboxExcludPerf"></td>
<td style="vertical-align: top; width: 32%;"><label for="Exclude_Perf">Exclude Win32_Perf classes</label></td>
<td style="vertical-align: top;"><input type="checkbox" name="Hide_Update" id="Hide_Update" onclick="OnClickCheckboxHideUpdate"></td>
<td style="vertical-align: top; width: 32%;"><label for="Hide_Update">Hide update notification</label></td>
<td style="vertical-align: top;" title="E.g. 'SCSILogicalUnit' will be displayed as 'SCSI Logical Unit'"><input type="checkbox" name="Use_Spaces" id="Use_Spaces" onclick="OnClickCheckboxUseSpaces" ></td>
<td style="vertical-align: top; width: 32%;" title="E.g. 'SCSILogicalUnit' will be displayed as 'SCSI Logical Unit'"><label for="Use_Spaces" >Use spaces in property descriptions</label></td>
</tr>
</table></th>
</tr>
<tr align="Center">
<td colspan="2"><table style="width: 100%;">
<tr>
<th style="width: 33%; vertical-align: bottom; text-align: left;" title="Select a WMI class from this drop-down list, then select a scripting language and press the 'Generate Code' button to show the code for the selected WMI query and the selected scripting language in the lower text area" align="Left">Select a WMI Class:</th>
<th style="width: 33%; vertical-align: bottom;">NameSpace: <select id="NameSpaces" title="This list shows the available WMI namespaces" size="1" style="width: 15em;" onchange="HandleNameSpaceChange" ></select></td>
<th style="width: 33%; vertical-align: bottom; text-align: right;"><input id="SettingsButton" onclick="ToggleSettings" type="submit" value="Configure" class="Button" title="Press this button to change the program's configuration"></th>
</tr>
</table></td>
</tr>
<tr align="Center">
<td colspan="2" title="Select a WMI class from this drop-down list, then select a scripting language and press the 'Generate Code' button to show the code for the selected WMI query and the selected scripting language in the lower text area"><select onchange="HandleClassChange" name="WMIClasses" id="WMIClasses" size="6" style="width: 100%"></select></th>
</tr>
<tr align="Center">
<th title="This list shows the available properties for the selected WMI class" align="Left">Properties:</th>
<th title="This list shows the available methods for the selected WMI class" align="Left">Methods:</th>
</tr>
<tr align="Center">
<td style="width: 50%"><select id="Properties" title="This list shows the available properties for the selected WMI class" size="6" style="width: 100%"></select></td>
<td style="width: 50%"><select id="Methods" title="This list shows the available methods for the selected WMI class" size="6" style="width: 100%"></select></td>
</tr>
<tr align="Center">
<th id="CodeLabel" title="After pressing the 'Generate Code' button, the generated code to display the available properties and their values for the selected WMI class will be shown here" align="Left">Code:</th>
<th align="Right"><input id="GetHelpButton" onclick="GetHelp" type="submit" value="MSDN Help" class="Button" title="Press this button to search and open the relevant MSDN page for the selected class, method and/or property"></th>
</tr>
<tr align="Center">
<td colspan="2"><textarea id="Code" rows="20" cols="70" readonly wrap="off"></textarea></td>
</tr>
<tr align="Left">
<th colspan="2" title="Select a scripting language from this drop-down list and press the 'Generate Code' button to show the code for the selected WMI query and scripting language in the text area above" align="Left">Select a scripting language:
<select name="CodeLanguage" id="CodeLanguage" onchange="HandleLanguageChange" style="text-align: left; margin-left: 0">
<option value="Batch">Batch</option>
<option value="C#">C#</option>
<option value="F#">F#</option>
<option value="Java">Java</option>
<option value="JScript">JScript</option>
<option value="KiXtart">KiXtart</option>
<option value="ObjectRexx">Object Rexx</option>
<option value="Perl">Perl</option>
<option value="PowerShell">PowerShell</option>
<option value="Python">Python</option>
<option value="Ruby">Ruby</option>
<option value="VB.NET">VB. NET</option>
<option value="VBScript">VBScript</option>
</select></th>
</tr>
<tr align="Center">
<td colspan="2"><table>
<tr>
<td><input id="GenerateCodeButton" onclick="ShowCode" type="submit" value="Generate Code" class="Button" title="Press this button to generate the code that will display the properties and their values for the selected WMI class, in the selected scripting or programming language"></td>
<td><input id="RunCodeButton" onclick="RunCode" type="submit" value="Run WMI Code" class="Button" title="Press this button to run the generated (VBSCript) code"></td>
<td><input id="ClearCodeButton" onclick="ClearCode" type="submit" value="Clear" class="Button" title="Press this button to erase the generated code"></td>
<td><input id="CopyCodeButton" onclick="CopyCode" type="submit" value="Copy to Clipboard" class="Button" title="Press this button to copy the generated code to the clipboard"></td>
</tr>
<tr><td colspan="4"> </td></tr>
<tr valign="bottom">
<td><input id="HelpButton" onclick="HelpMsg" type="submit" value="Help" class="Button" title="Press this button to display the command line help window"></td>
<td colspan="2" align="Center" style="color: black;"><span style="font-size: 12pt">WMI Code Generator, Version <span id="AppVersion">0.00</span></span><br>
© 2006 - 2011, Rob van der Woude<br>
<a href="http://www.robvanderwoude.com/wmigen.php">http://www.robvanderwoude.com/wmigen.php</a></td>
</td>
<td><input id="CreditsButton" onclick="Credits" type="submit" value="Credits" class="Button" title="Press this button to display the credits window"></td>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
</html>
|
page last uploaded:
7 December 2011, 09:25 |