Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to suspend running VMs when the host system (Windows 7 Pro, latest VMware Workstation: 9.0.1 build-894247) shuts down ("Keep VMs running after Workstation closes" is enabled inside VMware Workstation). Using gpedit.msc I added a shutdown script containing the following:

del c:\shutdown_script_was_executed.txt

"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" suspend "C:\myvms\sampleVM\sampleVM.vmx"
"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" suspend "C:\myvms\sampleVM2\sampleVM2.vmx"
"C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" suspend "C:\myvms\sampleVM3\sampleVM3.vmx"

echo 1 > c:\shutdown_script_was_executed.txt

The script works fine when being executed manually (VMs are being suspended) and it is also executed on shutdown (c:\shutdown_script_was_executed.txt is created), however when powering on the host again and starting VMware Workstation, the VMs are powered off and not suspended.

Any idea why this happens? Why are they not suspended?

Thanks for any hint!

share|improve this question

migrated from serverfault.com Jan 27 '13 at 1:25

This question came from our site for professional system and network administrators.

2 Answers 2

up vote 1 down vote accepted

Solution: Run the VM as shared VM (http://blogs.vmware.com/workstation/2012/02/vmware-workstation-8-as-an-alternative-to-vmware-server.html) and use a Windows shutdown script (logoff won't work (testing your script as local administrator also fails due to the same reason), because shared VMs are executed by a service running as a more privilieged user (probably SYSTEM, didn't check). Use vmrun.exe with suspend parameter in the shutdown script.

share|improve this answer

This happens because of the timing. When your shutdown script is executed, the virtual machine process(es) have already quit. You could confirm this by having your shutdown script record the output of vmrun list which will tell you there are 0 running VMs.

You might try using a logoff script instead of a shutdown script, but I'm 90% sure that is still too late.

share|improve this answer
    
sounded very promising, but to my surprise, it does not work - script is executed on logoff, but the VMs are not suspended! –  stefan.at.wpf Jan 28 '13 at 19:50
    
I checked this, when the logoff script is being called, the VMs are already killed / vmrun lists tells me, there are 0 running VMs \: –  stefan.at.wpf Feb 1 '13 at 15:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.