Virtualization Company Logos Sun.com Intel.com AMD.com HP.com RedHat.com Apple.com SWSoft.com VMware.com Parallels.com Microsoft.com cj tracking image cj tracking image
VBScript, quick and dirty check to Virtual Host
April 8th, 2007 under Intel, x86 Virtualization, Virtualization, Enterprise Computing, Microsoft, VMWare, News

This is a modification of the script shown at the Virtualization lab. I have added the other popular vendor, so now it checks for VMware and Microsoft hardware bits, and returns a simple message of the status. It checks to see if Microsoft is the motherboard manufacturer or if the computer system is from VMware. Pretty simple, and quick.

Here is the code:
—Start of Code—

Dim virtual
virtual = false
Set objWMIService = GetObject(”winmgmts:\\.\root\cimv2″)

Set colItems = objWMIService.ExecQuery(”Select * from Win32_BaseBoard”)
For Each objItem in colItems
if InStr(objItem.Manufacturer, “Microsoft”) then
wscript.echo “In Microsoft virtual machine”
virtual = true
end if
Next

Set colItems = objWMIService.ExecQuery(”Select * from Win32_ComputerSystem”)
For Each objItem in colItems
If InStr(objItem.Manufacturer, “VMware”) Then
WScript.Echo “in VMware virtual machine”
virtual = true
End If
Next

if virtual = false then
wscript.echo “Not inside a VMware or Microsoft virtual machine”
end if

—End of Code—

Save as virtual.vbs and run from command prompt as cscript virtual.vbs (once in the correct directory)

These is so much more you could do with this script, such as checking for MAC address, or other known virtual hardware combinations. The idea of the script is just so know can run a quick check to make sure you are running on the hardware you think you are. I’m working on building hardware profiles of different guest operating system configurations, this may be done later this week. The reason for this is to better understand the variations between guest machines, and best match your virtual hardware needs with the options on the market.



One Response to “VBScript, quick and dirty check to Virtual Host”

  1. Eric SloofNo Gravatar Says:

    Hello,

    I wrote an interesting article about using VB.net and writing your own applications to control your VI3 infrastructure. You can find it on the following location: http://www.ntpro.nl/blog/archives/130-Building-VMware-Visual-Basic-Applications.html

    Regards,

    Eric Sloof

Leave a Reply