I found myself a few weeks ago needing to find a way to get the type of machine for a program I am building, there's a few way to do this but the easiest way I found to do it at the time was via VBS. I'm unsure if anyone will find this useful, but I know I'll likely come back to this at one point.
The above, if saved in a notepad and saved as a .vbs script will come back with a number, the below table outlines what each number means.
|4||Low Profile Desktop|
|17||Mini System Chassis|
|20||Bus Expansion Chassis|
|23||Rack Mount Chassis|