VMware Communities
LifeIsGreat
Contributor
Contributor

Automatic shutdown or suspend of Guest when I shutdown the Host

Want to setup up VM Workstation to automatically either Shutdown or Suspend guests[/b] (2 VMs) when I choose to shut down the Host[/b].

So when I shutdown Host[/b] I want the Guests[/b] to automatically either suspend or shutdown (my choice) first before it shuts down the Host[/b].

Is this possible?

-JJ

9 Replies
KevinG
Immortal
Immortal

This is not a feature of VMware Workstation, but is available in VMware Server.

It maybe possible to create a script in your environment, depending on the host OS you are using.

Reply
0 Kudos
nuander
Enthusiast
Enthusiast

Easy Peasy - I've set up my host to suspend my guest server when the UPS battery power reaches a certain level.

Setup a batch file (e.g. suspend.bat) on the host with a command in it like this one "c:\Program Files\VMware\VMware Workstation\vmrun.exe" suspend "D:\Virtual PC\Windows SBS 2003\Windows Server 2003 Small Business.vmx"

Then set it run when the host shuts down by placing the batch file in "C:\WINDOWS\system32\GroupPolicy\Machine\Scripts\Shutdown" and then opening the Group Policy editor "gpedit.msc" and then in "Computer Configuration - Windows Settings - Scripts" add your batch file to the shut down script option.

OR to set up a suspend on loss of power like I did, on the Host go to "control panel - Power Options - Alarms - Alarm action" and set it to run your batch file. Supposedly Workstation 6 now supports battery power monitoring so it may be possible to implement a power-down of the Guest OS from within the guest, but I don't know of any way to make a guest suspend itself.

Cheers

Reply
0 Kudos
tsquillario
Contributor
Contributor

Is this still the best way to do it with Workstation 6.5? I just wanted to check and see if any new features were added making the graceful shutdown of guests easier.

Reply
0 Kudos
Matthias0815
Contributor
Contributor

Now 7.1.2 ist the current version - are all information in this thread still the only possibility?

And when I want to shutdown (or suspend) all running VMs?

I tried using "vmrun list" and then parse the output to detect the running VMX paths.

But I was unable to parse the command output with a Windows batch file...

Any suggestions?

Reply
0 Kudos
continuum
Immortal
Immortal

?

"vmrun list" does output a list of the paths




_________________________

VMX-parameters- WS FAQ -[ MOAcd|http://sanbarrow.com/moa241.html] - VMDK-Handbook


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
Noel
Expert
Expert

I tried using "vmrun list" and then parse the output to detect the running VMX paths.

But I was unable to parse the command output with a Windows batch file...

Any suggestions?

Installing Python would be a start.

Reply
0 Kudos
kopseng
Enthusiast
Enthusiast

I found it quite hard to find a solution to this originally, so I put it up on GitHub for easier retrieval once I did. You can find it here. I have also updated a corresponding SuperUser questions to guide more people in this direction. Feel free to post bugs or improvements in the repo.

piyushsachan
Contributor
Contributor

Thanks @kopseng  :thumbs_up: this has been working perfectly on Windows 11 with VMware Workstation 17. 

kopseng
Enthusiast
Enthusiast

Glad to hear it! I found the current state to be a 4/5 solution: fixing almost all the cases. There seems to be a situation every few months where Windows seems to have restarted when I get to work, for whatever reason, and the script has not hibernated the VMs, but mostly it just works. Could of course be that Windows crashed, the machine was power cycled, power was cut, etc, which is impossible to guard against :slightly_smiling_face:

Some months ago the file system of my Ubuntu VM seems to have gone corrupt, and for a while I started just working with WSL2, finding out that it can launch native Linux GUI apps such as IntelliJ side-by-side with other Windows app. After finding that worked so well, I simply haven't bothered to boot VMWare and reinstall the VM, but it was a good 5 years where this script proved useful! If someone needs some improvements I am still willing to accept pull requests :slightly_smiling_face:

Reply
0 Kudos