IVMVirtualMachine::SetConfigurationValue method

[Windows Virtual PC is no longer available for use as of Windows 8. Instead, use the Hyper-V WMI provider (V2).]

Sets the value of the specified configuration setting for this virtual machine (VM).

Syntax

HRESULT SetConfigurationValue(
  [in] BSTR    configurationKey,
  [in] VARIANT configurationValue
);

Parameters

configurationKey [in]

The key used to identify the configuration value as stored in the "*.vmc" file.

Important

Changes should be made to "*.vmc" only using the SetConfigurationValue method. Changing "*.vmc" using any other method is not supported.

configurationValue [in]

The configuration value. This value cay be one of the following VARIANT types: VT_ARRAY|VT_UI1 (raw bytes), VT_BSTR (string), VT_UI4 (integer), or VT_BOOL (Boolean).

Return value

This method can return one of these values.

Return code/value Description
S_OK
0
The operation was successful.
E_INVALIDARG
0x80000003
The configurationKey parameter is NULL or empty or the configurationValue parameter is not a valid variant type.
VM_E_VM_UNKNOWN
0xA0040207
The configuration is unknown.
DISP_E_EXCEPTION
0x80020009
An unexpected error has occurred.

Remarks

The following values are supported for the configurationKey parameter.

configurationKey value Description Data type Default value
"hardware/bios/time_sync_at_boot"
"true" if the VM CMOS clock is to be synchronized with the host clock at boot; "false" otherwise.
"boolean"
"true"
"integration/microsoft/host_time_sync/enabled""
"true" if host time synchronization is enabled in the integration components; "false" otherwise.
"boolean"
"true"
"ui_options/auto_app_publish"
"true" if automatic publishing of applications is enabled in the integration components; "false" otherwise. This is also called virtual applications.
"boolean"
"true"
"ui_options/seconds_to_save"
Number of seconds to wait before saving the VM after all applications are closed. However, values below 20 and more than 4,294,968 have special meanings. For details, see the following list
0
Never save the VM.
1 20
Wait 20 seconds before saving the VM.
21 4,294,967
Wait the specified number of seconds before saving the VM.
4,294,968 4,294,967,295
Wait 4,294,968 seconds before saving the VM.
"integer"
300

This method provides low-level access to any configuration value. It can be used to set configuration values for customer-defined keys. Be careful if you use this method to set system configuration values, because no error checking is performed on the configuration value. Also, some configuration values cannot be changed while the virtual machine is running.

Configuration keys are located in the virtual machine's "*.vmc" file in XML format. The keys are stored in a hierarchical manner similar to the registry keys in Windows. To specify a specific subkey, a "key path" is constructed which specifies the various keys in a slash mark delimited format.

For example, to set the value of the "ram_size" key located in the following key tree:

<preferences>
  <hardware>
    <bios>
      <time_sync_at_boot type="boolean">true</time_sync_at_boot>

The configurationKey path string would be specified as follows:

"hardware/memory/ram_size"

If any of the keys in the desired tree have an "id" attribute value, the attribute and its value is embedded in the configurationKey path string immediately after its associated configuration key using the following bracketed format: "[@id="id_value"]".

For example, to set the value of the "golf" key located in the following key tree:

<preferences>
  <alpha>
    <bravo>
      <charlie>
        <delta id="1">
          <echo id="0">
            <foxtrot>
              <golf type="string">D</golf>

The configurationKey path string would be specified as follows:

"alpha/bravo/charlie/delta[@id=1]/echo[@id=0]/foxtrot/golf"

Requirements

Requirement Value
Minimum supported client
Windows 7 [desktop apps only]
Minimum supported server
None supported
End of client support
Windows 7
Product
Windows Virtual PC
Header
VPCCOMInterfaces.h
IID
IID_IVMVirtualMachine is defined as f7092aa1-33ed-4f78-a59f-c00adfc2edd7

See also

IVMVirtualMachine

IVMVirtualPC::SetConfigurationValue