How can I detect if I'm within a vm or not?
Time and again I've seen security programs where the description says "Please don't try to run this inside a VM, as the program will not be able to be started" or "The security program will say that it is not in a valid environment if run from a VM".
What I'm wondering here is: How can the programs detect if they are within a VM or not? Is there some flag somewhere that is set, or is it specific drivers?
22 Answers
How can I detect if I'm within a vm or not?
A quick way I've done this in the past is by using WMIC commands from the command prompt to query WMI name space objects for computer, make, model, and serial numbers.
You could program some logic to use WMIC results as part of the install process and if it detects something known you could make it check this as part of the logic indicating it's a VM, or perhaps you program it to find other values saying it is not a VM or both.
Get Hardware Serial Number:
WMIC BIOS GET SERIALNUMBERGet Hardware Model:
WMIC COMPUTERSYSTEM GET MODELGet Hardware Manufacturer:
WMIC COMPUTERSYSTEM GET MANUFACTURERResults from VM versus on VM
Non VM WMIC Results:
VM WMIC Results:
Further Resources:
1The topic was higlighted couple of times. Here are some hints dependig on OS:
- Detect virtualized OS from an application?
- How to detect if my application is running in a virtual machine?
- How to identify that you're running under a VM?