VMware {code} Community
fixitchris
Hot Shot
Hot Shot

Storing Variables in VMX

Is it possible to permanently store a variables inside the guest's VMX file? (This used to be possible with VMCOM)

0 Kudos
2 Replies
Steve_Jin
Expert
Expert

It's possible with VI SDK. The VirtualMachine object has a method called reconfigVM_Task() (http://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.VirtualMachine.html#reconfigure). The parameter is VirtualMachineConfigSpec. Just assign the key/value pair into the extraConfig property of the parameter. Upon the success of invocation, the key/values will be saved to the .vmx file.

Please make sure you don't have a conflicting key with any existing one. For that purpose, you could use Java naming convention like com.<companyname>.** for your keys.

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
fixitchris
Hot Shot
Hot Shot

I am still running Vmserver 2.0 so VI is not an option yet.

Could I use WritePrivateProfileStringW win32api to write to the vmx file?

Update: It somewhat works; the throws it off as well as the string values with no quotes... a simple stream writer implementation could fix these issues.

0 Kudos