I've been researching for several days now on how to distinguish programatically (C#) if my software (Windows) is running on a VM or a physical machine. The approaches I find are two:
- Test for specific attributes indicating you're running on a specific type of a VM (VMWare, AMI etc.). Disadvantage: And what if you're not running on them? And what if these attributes can easily be changed by the manufacturer?
- Try use WMI to determine that by querying for certain attributes: I saw at least five different pieces of code, all contradicting each other and with someone commenting "it doesn't work".
I find it very difficult to believe that we do not have a definitive solution for making that distinction. Can anyone share a robust piece of code for this problem?