Anyone have a good (long-term) approach to checking if one is running in a VM-Ware session. By long-term I mean - a method that is not likely to change with newer versions of VM-Ware ... any help, suggestions or just plain-old thoughts would be welcome.
#161686 - 2006-05-0603:58 PMRe: Running in VMWare ...
Howard BullockHoward Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
That is a good question. I have sent an email to our VM-Ware expert to see if he can shed some light on the subject. I also might have a need to determine if a computer is a virtual computer or not.
#161689 - 2006-05-0604:37 PMRe: Running in VMWare ...
Howard BullockHoward Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
In the short term can't you use ip address? If I understand the virtual computer has an ip address in a range close to the base address of the VM server.
Writing a package that will be adding varying global groups into a local group, depending on whether running in vmware or not. The ip-address thing sounds dodgey to me. It has to flawless.
function IsVMWare dim $objWMIService, $colItem, $objItem $objWMIService = GetObject("winmgmts:\\.\root\cimv2") $colItems = $objWMIService.ExecQuery("Select * from Win32_BIOS") For each $objItem in $colItems if instr($objItem.SerialNumber,"VMWARE") $ISVMWare=1 endif Next Endfunction
Doc, those values - they tell if your running within a vmware session ? or whether you have wmware installed on your machine ? Allen - I really think you hit the nail on the head there.
#161696 - 2006-05-0707:41 AMRe: Running in VMWare ...
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11629
Loc: CA
It tells you both if you have it installed and if you're running it.
The WMI method is good too on current versions but you said you wanted something that was working on what would amount to older and newer versions, not so sure that exact same code would work on the older versions or not.
At the time back when I wrote it (as I recall) the names of the service were different on different versions or something like that that disuaded me from using that method. That may no longer be the case. VMware was not quite as large or "Corporate" back when I wrote the code.
If I were to do it now days I'd go with WMIConfirm() and VMwareState($Running) sort of code.
#161699 - 2006-05-0711:13 AMRe: Running in VMWare ...
CoCo
MM club member
Registered: 2000-11-20
Posts: 1342
Loc: NL
What VMware? Since there is Workstation, (GSX) Server which has to be installed on a host OS and there is ESX Server which has its own kernel... Take a look at www.VMTN.net, You will find there a great forum and knowledge base...
#161700 - 2006-05-0711:40 AMRe: Running in VMWare ...
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11629
Loc: CA
Here Shawn,
This code will tell you IF you're running under a VMware hosted Windows session. Not tested on GSX/ESX but should work on them as well due to the nature of the check.
If the system is not running the VMware Tools then it's not setup very well, and if it's not running the VMware Tray then it's been highly modified and is unlikely.
This method should work even if WMI is broken and a little faster as well.
Ok guys - I have tested all the solutions and they all work great. Will be having a meeting on Monday to decide which one to go with ... also, found this other method using srvinfo:
Just by way of an update. Just finished our meeting. We had four options on the table:
1) Use script and WMI (allen) 2) Check registry run values (ntdoc) 3) Use srvinfo | find 4) Check for VMTools service (ntdoc)
We liked options 1 and 2 equally - but decided to go with option #2 because we cant call-out to vb-script using the packaging method that we are using (some kind of install-shield thing).