Jump to content

Recommended Posts

Posted

Hi to all i want to write an application to sync file between my pc and the virtual machine running on it.Now the question is...How i can detect if my application is running inside a Virtual Machine?

HI!

Posted (edited)

What VirtualMachine are you using? This might help you in your quest in finding the answer >> http://www.codeproject.com/KB/system/VmDetect.aspx

Edit: Seems UEZ & water have more appropriate answers.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

You can use WMI and check for Manufacturer in Win32_BIOS or Vendor from Win32_ComputerSystemProduct.

Both values are on my vm: VMware, Inc. and VMware Virtual Platform

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

This example script might be useful as well:

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)

Try this, idea came from UEZ & water >> I've tested on VirtualBox & it worked, so you might have to tweak the SRE.

MsgBox(64, "_IsVirtualMachine()", _IsVirtualMachine())

Func _IsVirtualMachine() ; Returns 1 or 0.
    Local $oWMIService = ObjGet("winmgmts:\\localhost\root\cimv2")
    Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_ComputerSystemProduct", "WQL", 0x30)
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            If StringRegExp($oObjectItem.Name, '(?i)VirtualBox|VMWare|Virtual PC') Then
                Return 1
            EndIf
        Next
    EndIf
    Return SetError(1, 0, 0)
EndFunc   ;==>_IsVirtualMachine
Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

I see that link: http://www.codeproject.com/KB/system/VmDetect.aspx

This code is obsolete, dont work now :mellow:

MsgBox(64, "_IsVirtualMachine()", _IsVirtualMachine())

Func _IsVirtualMachine() ; Returns 1 or 0.
    Local $oWMIService = ObjGet("winmgmts:\\localhost\root\cimv2")
    Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_ComputerSystemProduct", "WQL", 0x30)
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
            If StringRegExp($oObjectItem.Name, '(?i)VirtualBox|VMWare|Virtual PC') Then
                Return 1
            EndIf
        Next
    EndIf
    Return SetError(1, 0, 0)
EndFunc   ;==>_IsVirtualMachine

This work well =)...im not a SRE guru but it seems to work.

Thanks!

Edited by StungStang

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...