Rob van der Woude's Scripting Pages

Help for WMIGen.hta

Version 9.03

Important Notice

This help page is for the HTA version of WMIGen (WMI Code Generator) only!

Development on the HTA version of WMIGen has been discontinued.

I rewrote WMIGen almost from scratch in C# to get a compiled program.

You can continue using this HTA version if you choose so, but it will no longer be maintained.

Click here to go to the current WMIGen page.

 

 

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.
 
Interactive Usage
 
First 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.
 
Next, select a class from the dropdown list marked "Select a WMI class", or use the search field to jump to the first (or next) match.
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
 
Usage:   WMIGEN.HTA [ options ] [ switches ]
 
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: root/CIMV2)
  /WIN32   List Win32_* classes only
  /NOPERF   Exclude Win32_Perf* classes
  /FAST   Skip the query to populate the namespaces list, an "populate" this list with the value specified by the /NAMESPACE:namespace option only
  /LANGUAGE:language   Specifies the initial programming or script language; language value as listed in drop-down box, but without spaces (default: Batch)
  /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. "SCSI Logical Unit" instead of "SCSILogicalUnit" (ignored for Batch)
  /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
(e.g. /SIZE:1024x768)
  /BW   Change the HTA's style to high contrast black and white
  /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
(requires /CLASS and, optionally, /LANGUAGE and /NAMESPACE)
  /RUN   Run the generated VBScript code immediately
(requires /CLASS and, optionally, /NAMESPACE)
  /COPY   Copy the generated code or result to the clipboard
(requires /GENERATE or /RUN)
  /SAVE:"filename"   Save the generated code or result to a file
(requires /GENERATE or /RUN; existing files will be overwritten without confirmation)
  /? or /HELP   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 formatted as a single command line, e.g. /WIN32 /NOPERF /LANGUAGE:C#
   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:
  • /CLASS:"class" /GENERATE /COPY
  • /CLASS:"class" /GENERATE /SAVE:"filename"
  • /CLASS:"class" /RUN /COPY
  • /CLASS:"class" /RUN /SAVE:"filename"
/NAMESPACE:"namespace" and /LANGUAGE:"language" are optional, their default values root/CIMV2 and Batch will be used if not specified.
   4:  If the extension of filename is ".*", it will be replaced by an extension based on the selected language, i.e. ".bat" for Batch, ".cs" for C#, etcetera, or by ".txt" for WMI query results.
   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 (%windir%\SysWOW64\mshta.exe). As a result, you would get the error message regardless of privileges.
In that case, add the path to the proper (64-bit) MSHTA to this HTA's command line:

%windir%\system32\mshta.exe "d:\path\WMIGen.hta" [ options ]
   6:  Also on startup, the HTA checks if an update is available, and will prompt you to download and install it if so.
 
Examples:   WMIGEN.HTA /WIN32 /NOPERF /SIZE:1024x768
  WMIGEN.HTA /NAMESPACE:root/SecurityCenter2
  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"

 

WMI Code Generator,  Version 9.03
© 2006 - 2016 Rob van der Woude
http://www.robvanderwoude.com/wmigen.php


page last uploaded: 2016-10-11, 12:29