|Select a scripting language:|
|Configuration file content:|
|Windows size (widthxheight or maximize)|
|Default output language|
|Generate source code in the selected scripting or programming language, for the selected WMI query|
|Use this HTA to generate Batch, C#, Delphi, F#, Java, JScript, KiXtart, Lua, Object Pascal, (Open) Object Rexx, Perl, PowerShell, Python, Ruby, VB .NET or VBScript code for selected WMI queries.|
|First select a WMI namespace from the dropdown list, or stick with the default (
If a warning message, suggesting to abort the script, appears after selecting a namespace, click "No" to continue reading the list of available classes.
|Next, select a class from the dropdown list marked "Select a WMI class".
The "Properties" and "Methods" fields will show the properties and methods available for the selected class, if any.
|To get detailed information on a class or a method or property, select that class (and optionally a method or property) and click the "MSDN Help" button.
This will open your default browser with a list of relevant Google Search results.
|Select a scripting or programming language from the drop-down list and click the "Generate Code" button to generate the code that will display all properties of the selected class, and their values, in the scripting or programming language of your choice.|
|To test the selected query on your own computer, click the "Run WMI Code" button and wait for the result to appear on screen. Click "Generate Code" once more to redisplay the code in the selected scripting language.|
|Click "Save" to save the generated code (or query result) to a file, or "Copy" to copy it to the clipboard.|
|Command Line Usage|
|Options:||The following options can be set in the configuration file or on the command line
(in case of conflicts, the command line overrules the configuration file)
|/NAMESPACE:namespace||Specifies the initial WMI namespace to be opened (default:
|/FAST||Skip the query to populate the namespaces list, an "populate" this list with the value specified by the
|/LANGUAGE:language||Specifies the initial programming or script language;
|/LOWRES||Generate code that uses less resources, at the cost of the results being "read-once" only (ignored for C#, F#, Java, Lua, PowerShell and VB.NET)|
|/SPACES||Insert spaces in property name descriptions, e.g. "
|/WRAP||Enable (soft) word wrap in the generated code field (does not affect saved code)|
|/SIZE:WxH||Center window and resize to W x H pixels
|/BW||Use high contrast black and white style for this HTA window|
|/NOUPD||Skip check for updates at startup|
|Switches:||The following options can only be set on the command line|
|/CLASS:class||Specifies the WMI class to be selected|
|/GENERATE||Generate the code immediately
|/RUN||Run the generated VBScript code immediately
|/COPY||Copy the generated code or result to the clipboard
|/SAVE:"filename"||Save the generated code or result to a file
||Show this message|
|Notes:||1:||The optional configuration file is named "WMIGen.cfg", and must be located in the same folder where this HTA is located.
"WMIGen.cfg" is formated as a single command line, e.g.
|2:||Command line arguments will always prevail over "WMIGen.cfg" settings!|
|3:||To run without any user interaction requires one of the following combinations of command line arguments:
|4:||If the extension of
|5:||On startup, the HTA checks if it is running with elevated privileges, and displays an error message if not.
On 64-bit systems, HTAs may be incorrectly associated with the 32-bit MSHTA.EXE (
In that case, add the path to the proper (64-bit) MSHTA to this HTA's command line:
|6:||Also on startup, the HTA checks if an update is available, and will prompt you to download it if so.|
|Examples:||WMIGEN.HTA /WIN32 /NOPERF /SIZE:1024x768|
|WMIGEN.HTA /NAMESPACE:root/WMI /CLASS:WmiMonitorID /GENERATE /SAVE:"monitor_inventory.bat"|
|WMIGEN.HTA /NAMESPACE:root/WMI /CLASS:WmiMonitorID /RUN /COPY
PASTE.EXE >> monitor_inventory.txt
|WMIGEN.HTA /CLASS:Win32_BIOS /LANGUAGE:C# /GENERATE /SAVE:"bios_query.cs"|
Based on the Microsoft TechNet ScriptCenter article Scripting Eye for the GUI Guy.
Java code based on NickDMax's JACOB sample on DreamInCode.net.
Lua code based on "test_wmi.lua" example that comes with the Lua for Windows installation package.
Ruby code based on David Mullet's Using Ruby & WMI to Get Win32 Process Information.
Check for elevated privileges by Denis St-Pierre.
WMI Code Generator, Version 0.00
© 2006 - 2013 Rob van der Woude