views:

1298

answers:

3

How can I detect (.NET or Win32) if my application is running in a virtual machine?

+5  A: 

Here is an example of one way to do it. It only works with Microsoft's Virtual PC and VMWare, but it's a start: http://www.codeproject.com/KB/system/VmDetect.aspx

Arthur Chaparyan
That is very interesting... seeing how the machines reacts to using invalid assembly commands. Awesome!
Jason
I searched "detect if running in virtual machine" (without the quotes) in Google and it was the first result.
Arthur Chaparyan
Actually the best way is "hardware fingerprinting":http://blogs.msdn.com/virtual_pc_guy/archive/2005/10/27/484479.aspx
Arthur Chaparyan
+5  A: 

Take the red pill.

Jay Bazuzi
this is funny but true :)
lubos hasko
+6  A: 

According to Virtual PC Guy's blog post "Detecting Microsoft virtual machines", you can use WMI to check the manufacturer of the motherboard. In PowerShell:

 (gwmi Win32_BaseBoard).Manufacturer -eq "Microsoft Corporation"
Jay Bazuzi