Click here to Skip to main content
15,885,141 members
Articles / .NET

Strong Type Gen – MgmtClassGen.exe Command Line Builder

Rate me:
Please Sign up or sign in to vote.
2.00/5 (1 vote)
29 Jan 2013CPOL6 min read 24.7K   147   6   7
Strong Type Gen – MgmtClassGen.exe Command Line Builder

This is a program I completed on 10/16/2011 and I believe is finally ready for prime time.

Those that use the MgmtClassGen.exe tool should find this program very handy for creating the strong type classes quickly.

StrongTypeGen5.8.0.8

Before any selections or locations are saved.

Current Version as of 10/16/2011 is 5.8.2.8.

The Build

  • This program was initially started on Windows XP Pro 32 bit but was completed on Windows Vista 64 Bit version in Visual studio 2008. It has been written entirely in VB.NET.
  • This program is a stand alone program, no install is required. Just unzip and go.
  • Minimum requirement is .NET version 2.0.
  • File size is 146 KB.
  • The idea for the namespace / class list layout was actually inspired by the Microsoft Scripting Guys Scriptomatic 2.0, where I modified it to be able to view every namespace and class, not just the dynamic ones. Then I adapted the idea for this program.

Links

Known Issues

Builds of the strong type classes seem to fail if you choose an output folder away from the root (C:\Saved_Classes). I am not sure if it is folder permissions or a Path Length problem. It does not seem to matter on the location of the MgmtClassGen.exe file.

When choosing a MgmtClassGen.exe file, I have found it works best if you are running a 64 bit OS then use the file from the x64 folder otherwise use the one from the level above it. I have found no way to tell the difference in the 32 bit and 64 bit files because they have the exact same file version. There are also different .NET versions (see the screenshot below).

The program takes a few seconds to start up after clicking the program icon to find all of the namespaces.

When there are a lot of classes to load, it can take a few seconds to load the classes in the listbox. My system will load about 1011 cimv2 classes into the listbox, so just wait till the count is up and then it's ready.

Location of the MgmtClassGen.exe for the program is hardcoded in the button click to the path C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64. If the program fails to find the folder, then it seems to revert to the current user documents folder.

While testing the program for the VJ – JSharp (J#), it failed to build that version even after trying different .NET versions of MgmtClassGen.exe. So I took that build option out.

I found a link to the redistributable for J#, it may work if that was installed.

It wouldn’t take much to put it back in or to just amend the argument string for the VJ for the type and the file extension using a different language version.

MgmtGenVerFound

This program was built just for finding all files by exact filename only. So I could find all versions of the MgmtClassGen.exe file and sort by file version.

As you can see from the screenshot above, I found 4 different .NET File versions in various back up folder locations. Still, remember to use the correct version for the Bit Version of your OS.

In the screenshot below, I added a label to show the bit version of the Operating System you are running the program on as a reminder of what version to use (in case you are running this on an unfamiliar system).

The Program

mgmtclassallselected-b

By the Numbers

  1. Select a namespace
  2. Select a class
  3. Select the output language desired
  4. Select the location to output the file to
  5. Select the location of the MgmtClassGen.exe folder
  6. Click button to generate the full command line argument
  7. Right click and copy the full command line argument
  8. Click the button to open a command window to the location specified in step 6. It uses the location as an argument when opening the command window to that location. You can change locations for each .NET version without regenerating the command line arguments. You just have to open a new command window to the location for the version used.

mgmtclass3b

  1. Paste the generated command line arguments and hit enter . If there are no problems, then above is what you will see. Otherwise, you see one of the next screenshots.

mgmt2.0.507277.42

MgmtClassErrorXP1Crop

This happens when the command line arguments are wrong, when you specify a folder location on the desktop, or for some reason it is not supported. Top was from pointing the MgmtClassGen at a location that did not contain the file. Bottom picture is from the Windows XP test.

If you want to generate several classes using the same .NET version of the MgmtClassGen.exe file, then just change the class and regenerate the command line arguments. You can generate several classes very quickly with this program.

If you would like to see what the classes are, then you can always use the Scriptomatic V2.0.

Remember though that there version only shows the Dynamic classes.

Direct link to download:

Or through the script center download link:

I will make my highly modified version of the Scriptomatic 2.0, ClassNFOMatic22. “HTA” available at a later date. I’m still redesigning my script section on my web site. My version only supports VB, but it does list all classes.

Settings

MgmtClassSettings

There is not to much to the settings, just click on the label named Settings. It just saves the location for the output folder and the MgmtClassGen.exe folder locations. Pretty easy to use, at least I think so.

Testing The Application

  • I tested this program on Windows Vista Ultimate 64 bit Quad Core (also the build system).
  • Tested on Windows 7 Ultimate 64 Bit Quad Core (Dual boot)
  • Windows 7 Professional 32 bit Single Core (older Laptop)
  • VM Windows Vista Business 32 bit all worked but C++ would not work on VM
  • VM Win XP Pro sp. 3 32Bit all worked but C++ would not work on a VM (Virtual Machine)
  • I also found out through my onload event the XP version did support the My.settings reference and I had to add error handling to the onload event to take care of the runtime error that popped up.

So steer clear of VMs and XP for generating the classes.

Updated:

1/29/2013 Removed Link to my website. Had to let site go.

Program updated to add a splash screen to take up the time for the on load while it is gathering the namespaces, so it does not appear unresponsive.

Also added the Zipfile for download thru here, Since my current download location may dissapear in May.

Current version is now 6.2 as of December 20 2011

If there are any questions, you can post here or contact me thru the send private email.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO PC's Xcetra
United States United States
My first experience with computers was when my mom gave a Timex Sinclair 1000 to me for Christmas some time in the late 70's (I still have it)There I learned to copy code from magazines to save to cassette tapes for playing games.

Since then I have dabbled in:
Basic,Qbasic,ruby,python,Java Script, HTML, CSS, C#, C++, Perl, and a few other I can't think of off hand.
Now I Mainly work with VB Script and VB.Net
I Prefer to build programs that make use of the GUI so I don't have to remember all of the syntax for console apps. I realy don't care much for HTML because of the way you build and then run to see if it looks right. Also the new WPF is to much like HTML so I steer clear of it for now.
Most of what I build is for getting information from a system to use in system repair.I make heavy use of the WMI classes. Why reinvent something.

Comments and Discussions

 
GeneralMy vote of 2 Pin
Klaus Luedenscheidt1-Jul-12 18:57
Klaus Luedenscheidt1-Jul-12 18:57 
GeneralRe: My vote of 2 Pin
ledtech38-Jan-13 14:49
ledtech38-Jan-13 14:49 
GeneralRe: My vote of 2 Pin
ledtech329-Jan-13 17:18
ledtech329-Jan-13 17:18 
SuggestionImages Pin
Wendelius1-Jul-12 5:26
mentorWendelius1-Jul-12 5:26 
GeneralRe: Images Pin
ledtech31-Jul-12 5:28
ledtech31-Jul-12 5:28 
GeneralRe: Images Pin
Wendelius1-Jul-12 7:59
mentorWendelius1-Jul-12 7:59 
GeneralRe: Images Pin
ledtech31-Jul-12 8:39
ledtech31-Jul-12 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.