Open topic with navigation
InstallShield lets you determine whether an installation is running on any of the following types of virtual machines:
|•||A VMware product such as VMware Player, VMware Workstation, or VMware Server|
|•||Microsoft Virtual PC|
To check for virtual machines, you can either use Windows Installer properties, or you can use an InstallScript structure or function.
Note: Emulators such as Bochs and QEMU are not detected.
Using Windows Installer Properties to Detect a Virtual Machine
Project: You can use Windows Installer properties in conditions for items such as features, components, and custom actions in the following project types:
To use Windows Installer properties to detect the presence of a virtual machine and determine the type of virtual machine, you first need to create a custom action that calls the ISDetectVM function in the SetAllUsers.dll file.
To add a custom action that checks for a virtual machine:
|1.||In the View List under Behavior and Logic, click Custom Actions and Sequences (in Basic MSI and InstallScript MSI projects) or Custom Actions (in DIM and Merge Module projects).|
|2.||In the center pane, right-click the Custom Actions explorer, point to New MSI DLL, and click Stored in Binary table. InstallShield adds a new custom action.|
|3.||Change the name of the action to something like ISDetectVM.|
|4.||Configure the custom action’s settings in the right pane:|
|•||In the DLL Filename setting, select the SetAllUsers.dll file. The typical path is:|
|•||In the Function Name setting, enter the following name:|
|•||In the In-Script Execution setting, select Immediate Execution.|
|•||Schedule the custom action as needed by selecting the appropriate option in one or more sequence settings.|
The custom action sets the following Windows Installer properties at run time:
If the value of this property is 1, the installation is running on one of the following virtual machine environments:
If the value is not set, no virtual machine has been detected.
This property indicates the type of virtual machine that is running the installation. Available values are:
You can use the aforementioned properties in conditional statements. For example, if your product cannot be used on virtual machines, enter the following conditional statement in the Install Condition setting of the General Information view:
If you have a component that should be installed only on VMware images, enter the following conditional statement in the Condition setting of the Components view:
Using an InstallScript Structure and Variable to Detect a Virtual Machine
Project: You can use an InstallScript structure and variable in event-driven InstallScript code in the following project types:
You can also use the structure and variable in InstallScript custom actions that are in the following project types:
You can use the SYSINFO.bIsVirtualMachine structure in your InstallScript code to determine whether the installation is being run on a virtual machine. In addition, you can use the VIRTUAL_MACHINE_TYPE constant with the GetSystemInfo function to determine which type of virtual machine is present.
For example, in an InstallScript event handler such as OnFirstUIBefore or in an InstallScript custom action, you can use code such as the following snippet:
if (SYSINFO.bIsVirtualMachine) then
SprintfBox (0, "VM", "This is a virtual machine. Type: %d",
GetSystemInfo (VIRTUAL_MACHINE_TYPE, nNumber, szString));
MessageBox ("This is not a virtual machine.", 0);
At run time, a message box is displayed. If the target system is a Microsoft Hyper-V image, a VMware image, or Microsoft Virtual PC, the message box says, “This is a virtual machine,” and it also lists the type of virtual machine. If the target system is not one of those virtual machines, the message box says, “This is not a virtual machine.”
Building Conditional Statements
InstallShield 2015 Help Library
|Copyright Information | Contact Us|