WMI Code Generator

Version 9.01

 

 

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 menu selected WMI queries.
WMI Code Generator 9.01 Screenshot
This HTA requires elevated privileges.
Elevated privileges required
Click "Settings" to open the settings screen, change them to your liking, click "Edit" to edit the configuration file in Notepad, or "Reset" to restore the program defaults; click "Save" or "Cancel" when done. These settings are permanent.
WMIGen 9.00 settings page
Clicking the "Help" button or pressing F1 opens the program's Help screen, listing all command line switches available, including those for non-permanent settings.
Clicking the "Credits" button opens the program's Credits screen.
Besides the "Back" or "Cancel" buttons, you can also use the "Esc" key to return to the main program screen.
Interactive use:
Select a WMI namespace from the dropdown list, or stick with the default (root/CIMV2).
If a warning message, suggesting to abort the script, appears after selecting a namespace, click "No" to continue reading the list of available classes.
Warning message if the HTA temporarily uses too much resources.
Select a class.
The "Properties" and "Methods" fields will show the names of the properties and methods available for the selected class.

To get detailed information on a class or a method or property, select that class and method/property, and click the "MSDN Help" button.
This will open a browser window with the relevant MSDN page, or if that page doesn't exist, or if more than 1 page exists, a list of 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.

Then save the code (or result) to a file, or copy it to the clipboard and paste it into your favorite scripting editor.
Command line:
Open the HTA's Help screen for details on the HTA's command line options.

 

Change History

Version Release Date
(yyyy-mm-dd)
Changes
9.01 2014-01-03
  • Corrected some HTML errors in the Help screen.
  • Added the WMIGen Help page to this website.
9.00 2014-01-02 A reshuffle of the user interface, plus some code optimization:
 
  • All permanent settings are displayed in their own window when the "Settings" button is clicked.
    All permanent settings can be changed interactively.
    The configuration file can be edited in Notepad by clicking the "Edit" button.
    The settings can be restored to "factory defaults" by clicking the "Reset" button.
  • The Settings, Help and Credits screens are all opened in the main program window, thus minimizing the chance of stray Internet Explorer leftover sessions after closing the HTA.
    Pressing the Escape key returns you to the main program window.
    In the Help and Credits screens, pressing the Backspace key will do the same.
  • CSS code has been added to allow the Help screen to be printed properly (open Help and press Ctrl+P to print).
  • Some switches got new names, some can no longer be used in the configuration file, but are now commandline-only; see the program's Help screen for details.
  • Unattended use has been improved by the addition of a new optional switch /SAVE:"filename" to save the code or result to a file; see the program's Help screen for details.
  • Fixed ambiguity issue with MSDN Help function.
  • The HTA checks if it is running with elevated privileges, and displays an error message if not.
8.20 2013-12-18
  • Added Lua to the list of supported languages (generated Lua scripts will require Lua for Windows).
8.10 2013-11-12
  • Update notification is now a MsgBox dialog instead of an inserted HTML block in the main window.
  • Each command line argument can now be saved in a configuration file "WMIGen.cfg"; just write the settings you wish to persist on a single line (e.g. /WIN32 /NOPERF /LANGUAGE:BATCH), and it will be appended to the actual command line; "real" command line arguments prevail over saved settings.
  • A checkbox "Remember these settings" has been added in the "Configure" block to allow creating a basic "WMIGen.cfg" file.
8.01 2013-05-23
  • Bug fixed by Aaron Mason in generated VBScript code.
8.00 2012-11-15
  • Added Delphi and Object Pascal to the list of supported languages.
  • Replaced (most of) the "legacy" HTML code by HTML/CSS code, fixed some HTML/CSS errors, and included a document type, to make the HTA work in Internet Explorer 10/Windows 8.
7.03 2011-08-16
  • Added Java to the list of supported languages.
  • Fixed a bug that would sometimes disable the "Generate Code" and/or "Run Code" buttons.
7.02 2011-08-11
  • Added a command line switch /CLASS:"class" to select the class the HTA opens with.
  • Added a command line switch /LANGUAGE:"language" to select the language the HTA opens with.
  • Added a command line switch /GENRATE to immediately generate the code for the selected namespace and class in the language of choice (requires /NAMESPACE, /CLASS and /LANGUAGE).
  • Added a command line switch /RUN to immediately run the generated (VBScript) code for the selected namespace and class (requires /NAMESPACE and /CLASS).
  • Added a command line switch /FAST to skip the queries to populate the namespaces and classes lists, and populate these lists with the selected values only (requires /NAMESPACE; /CLASS is optional, if not used, the list will still be populated using a WMI query).
  • Added a command line switch /COPY to copy the generated code or query results to the clipboard and close the HTA (requires /NAMESPACE, /CLASS and either /LANGUAGE and /GENERATE or /RUN); this allows the HTA to be run without interaction; use Paste.exe to read the results from the clipboard.
  • To prevent incorrect update notices, the update check now clears the Internet Explorer cache and rereads the latest version from the web (once) if it does not match the current version.
  • Some command line examples were added to the help text.
  • The help text has been moved to an Internet Explorer window, because it exceeds the maximum MsgBox message length.
7.01 2011-08-07
  • Fixed a bug in the MSDN Help function.
7.00 2011-08-06
  • Added a dropdown list to select alternative WMI namespaces, besides the default root/CIMV2.
  • Added a command line switch /NAMESPACE:"namespace" to select the default namespace the HTA opens with.
  • Added a checkbox in the settings to hide the update notification.
  • "Generate resource-friendly code" now affects more script languages (all but batch and the "true .NET languages").
  • Fixed a bug that could disable the "Generate Code" button after changing the "Generate resource-friendly code" setting.
  • Fixed, optimized and rewrote the routine that inserts spaces in property names.
6.24 2011-07-30
  • Fixed a bug in the handling of the /WRAP switch.
6.23 2011-07-30
  • Added an option (settings and command line switch /RESOURCEFRIENDLY) to restore the previously removed WQL and wbemFlagReturnImmediately + wbemFlagForwardOnly parameters in the generated ExecQuery statements for JScript, KiXtart, Perl and VBScript; using these parameters makes the WMI query results "read-once" and renders the .Count property useless, but the generated code will use less resources.
  • Added a choice to enable or disable (soft) word wrap in the code screen (settings and command line switch /WRAP).
6.22 2011-07-25
  • Removed the second and third parameter (WQL and wbemFlagReturnImmediately + wbemFlagForwardOnly) in the generated ExecQuery statements for JScript, KiXtart, Perl and VBScript.
    Thanks for Steve Robertson who found out that not using these parameters actually improves the code: you can now use the .Count property of the collection that ExecQuery creates, and reiterate through that collection as many times as you like.
6.21 2011-06-14
  • Generated Ruby code will now accept an optional remote computer name as command line argument.
6.20 2011-06-14
  • Improved Python code, it now works with Python 3.1 and handles properties of every type.
  • Improved VB .NET code, it now complies to Visual basic 2010.
  • Generated C#, Python and VB .NET code now accepts an optional remote computer name as command line argument.
  • The configuration settings are now hidden behind the new "Configure" button.
  • Spaces in property names (in the generated source code) are no longer inserted by default.
  • Added the following switches:
    /SPACES    insert spaces in property names (in generated source code)
    /SIZE:widthXheight   specify window size
    /HELP and /?   display command line help, also available by pressing F1
    /NOUPDCHK   skip check for updates at startup
6.11 2011-05-19
  • Improved F# code, it will now handle properties of every type.
6.10 2011-05-19
  • Added /NOSPACES and /Q switches, and interactive settings.
    With /NOSPACES the original property names will be used for descriptions, otherwise the descriptions will contain spaces to improve readability.
  • If no command line switch is used, a settings block will appear at the top of the page, allowing to interactively change the settings otherwise controlled by the command line switches.
    With /Q the settings section will remain hidden.
6.00 2011-05-19
  • Added F# to the list of supported languages.
5.10 2010-10-08
  • Added /WIN32 and /NOPERF switches, removed /ALL switch.
    By default, all classes in the ROOT\CIMV2 namespace are listed at startup.
    With /WIN32 only Win32_* classes are listed.
    With /NOPERF Win32_Perf* classes are excluded from the list.
5.00 2010-06-30
  • Added C# (assisted by my son Bas) and VB .NET to the list of supported languages.
4.10 2010-06-28
  • Added Ruby to the list of supported scripting languages.
4.01 2010-06-28
  • Corrected the URLs to my own site.
4.00 2010-06-28
  • Added a "Run WMI Code" button to test the selected WMI query.
3.00 2010-06-27
  • Replaced "Create ... Code" buttons by a drop-down list.
  • Optimized screen layout for large and small screens.
2.02 2010-01-25
  • Added doublequotes for the "node" name in the generated batch code, to prevent error messages if the computer name contains dahes (problem discovered and solved by David Chisholm).
2.01 2008-07-20
  • Corrected the URL to WMIGen.hta in the generated code.
  • Added alternating background colors in the dropdown list boxes.
2.00 2008-07-16
  • Added a "Help" button, which searches MSDN for a relevant reference page for the selected Class, Method or Property. To write the help function, this article from Search Engine Roundtable proved invaluable.
  • The properties and methods are no longer listed in HTML text areas, but in dropdown lists.
1.33 2006-10-20
  • Added BREAK ON statement in generated KiXtart code, to close all running processes when Ctrl+Break is pressed.
    Thanks for Senser for this tip.
1.32 2006-10-16
  • Added /ALL command line switch to display not only Win32_* classes, but all classes.
1.31 2006-09-11
  • Corrected an error in the generated JScript code.
1.30 2006-09-08
  • Now also generates Batch, Object Rexx, Perl and Python code.
  • Added the script language name in the comment lines of the generated code.
1.21 2006-09-05
  • Generated KiXtart and PowerShell script now support command line specified remote computer name.
1.20 09/05/2006
  • Besides PowerShell and VBScript, now also generates JScript and KiXtart code.
  • Added an empty line in the generated scripts, to distinguish between object instances.
  • Added a "Clear Code" button.
1.14 2006-08-30
  • Minor update: improved update/version check.
1.13 2006-08-21
  • Improved update/version check.
  • Added comments to the generated scripts.
1.12 2006-08-18
  • Improved window layout for low resolution displays.
  • Text areas are now resized when main window is resized.
  • Dynamic tool tip for "Copy Code" button.
1.11 2006-08-16
  • Added tool tips.
1.10 2006-08-15
  • Added automatic update check & notification.
  • Added background gradient.
1.00 2006-08-14
  • Initial release.

 

Download WMI Code Generator 9.01:

 

Checksums:
File name:
MD5:
SHA1:
 
wmigen.zip
ed096fda75b0c9aae57f4d048d785f69
d916f20283e27cfc948138664ef4ba144e708bb3

 

Make a donation:

page last uploaded: 22 January 2014, 17:24