How can I detect (.NET or Win32) if my application is running in a virtual machine?
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- the application was unable to start correctly 0xc0
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
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
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:
The easiest way I found to figure out whether my C# app is running on a vmware VM or not is to check the MAC address of the NIC card(s). If it's a VMware VM it would always be: 00:50:56:XX:YY:ZZ
You may enumerate through the NICs as resolved here.