Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Last week I showed you how to use GetConfigurationValue and SetConfigurationValue to change the BIOS configuration for a virtual machine. This week I would like to continue working with these API's and provide some more samples of how they can be used. Get and Set ConfigurationValue allow you to get and set any value in the virtual machine configuration file. This can be very useful for getting access to some of the more esoteric features of Virtual Server for which a direct COM interface does not exist. The script below uses these APIs to check and set the mouse integration setting for a virtual machine (as discussed here):
Set vs = CreateObject("VirtualServer.Application")
set vm1 = vs.FindVirtualMachine(WScript.Arguments(0))key = "integration/microsoft/mouse/allow"
currentValue = vm1.GetConfigurationValue(key)Wscript.echo "The state of mouse integration on " & WScript.Arguments(0) & " is: " & currentValue
if currentValue then
newvalue = false
Else
newvalue = true
End ifresult = vm1.SetConfigurationValue(key, cbool(newvalue))
Wscript.echo "The state of mouse integration on " & WScript.Arguments(0) & " has been set to: " & newvalue
This script takes the virtual machine name as a command line parameter, gets the current value for the mouse integration setting, informs the user of the current value, changes the configuration value to be opposite what it used to be, and then informs the user of this change.
Cheers,
Ben
Comments
- Anonymous
April 27, 2006
And the name is just an XPath into the .vmc XML, I guess? - Anonymous
April 28, 2006
You might also do a post on how to store user data in the VMC...
-Mike - Anonymous
April 30, 2006
Jonothan -
Correct.
Cheers,
Ben