0

Possible Duplicates:
Determine when running in a virtual machine
How to detect if my application is running in a virtual machine?

How can I check if Windows is installed on a virtual hard drive (VHD) or a physical drive using C#?

Community
  • 1
  • 1
Frayx
  • 363
  • 1
  • 5
  • 6
  • 1
    possible duplicate of [Determine when running in a virtual machine](http://stackoverflow.com/questions/779723/determine-when-running-in-a-virtual-machine) and [How to detect if my application is running in a virtual machine?](http://stackoverflow.com/questions/498371/how-to-detect-if-my-application-is-running-in-a-virtual-machine) – Dirk Vollmar Apr 28 '11 at 14:29
  • There is not a fool proof method. You can check for certain processor extensions that are enabled only in a virtual setting. You can also check to see if certain virtual hardware is installed. The hardware of course is different for each virtual machine vendor. Why exactly do you want to do this? – Security Hound Apr 28 '11 at 15:06

1 Answers1

0

If you open a virtual machine file in notepad, you will see it is just an xml file.

It contains information about the operating system, like:

        <version>
            <guest_os>
                <build_number type="string">6.01.7600</build_number>
                <long_name type="string">Windows&amp;reg; 7</long_name>
                <short_name type="string">Windows&amp;reg; 7</short_name>
                <computer_name type="string">Win7-PC.domain.com</computer_name>
            </guest_os>

How to check a physical drive? You could check if there is a Windows folder, but that is no guarantee ofcourse.

John xyz
  • 176
  • 5
  • 2
    I think he means from inside the virtual machine. – Hans Løken Apr 28 '11 at 14:49
  • If he's inside a VM and running a C# application, it's a fair bet that Windows is installed. The exception is for Mono-variant instances, so maybe in that case he should be looking for clues that the OS *isn't* Windows... – Eight-Bit Guru Apr 28 '11 at 15:21