How can you change a VMWare Workstation network adapter's vnet? (using vmrun preferably)

How can you change a VMWare Workstation network adapter's vnet? (using vmrun preferably)

I've been playing with vmrun for the last couple of hours trying to get Workstation 7.x change VM network connections (vnet) between different custom networks. e.f. VM A is configured for vnet2, I then use vmrun to change it to vnet3.

There's a good automation reason for having to do this but the project isn't lengthy enough to bother digging into VIX.

So far I can read the VM's runtimeCongfig for the ethernet device:

vmrun.exe readVariable C:\Working\Virtual\XYZ\XYZ-WWW\XYZ-WWW.vmx runtimeConfig ethernet0.vnet
VMnet2

And I can write changes to it:

vmrun.exe writeVariable C:\Working\Virtual\XYZ\XYZ-WWW\XYZ-WWW.vmx runtimeConfig ethernet0.vnet VMnet3

In Workstation you don't see a change. The VM's existing/loaded configuration is still the old one. (VMnet2, which is bad as I want it to be the new VMnet3 setting) If I call vmrun to get the ethernet0.vnet setting, it'll be VMnet3. (which is what I set it to, which is good)

If I manually disconnect the network interface, Workstation loads the config ethernet0.vnet setting and it displays that it's VMnet3. If I then connect the interface (right click on the VM's network icon in the bottom right and select Connect) it'll be on the correct network.

If I also suspend the VM, then restore it, it'll pick up the new runtimeConfig changes. (basically the runtimeConfig settings will be written to the .vmx file, then read again)

Is there a way to get this to work as expected? e.g. you make a change to the VM's runtimeConfig for networking, and it's either used or reloaded as needed? There is no vmrun command to reload the runtimeConfig, and when I suspend/start with vmrun, the start command tries to launch the VM in a completely new Workstation GUI window. (and it asks for ownership!?)

Thanks in advance!

Antwort1

During some vmrun testing I noticed that suspending a VM wouldn'ht write out the runtimeConfig to disk, and you couldn't use vmrun to writeVariable for ethernet0.vnet while the VM was not running. In the past I've manually changed a VM's MAC via editing the .vmx file, so I decided to try editing it myself while suspended, then starting it again. VMWare Workstation will pick up the .vmx changes when suspending/stopping the VM. (not pausing though) This was enough for me to write a batch script to handle editing the .vmx file. At least vmrun can suspend and start VMs.

It seems very counter-intuitive to me that VMWare would include vmrun with Workstation, where you can edit the runtimeConfig's variables and not actually use them! Try changing the displayName. You have to either manually or via vmrun, suspend then start the VM to see the changes. There should be an option to reload the runtimeConfig from .vmx.

verwandte Informationen