Is it possible to autostart a VMware virtual machine in background as a Windows service, and shut it down elegantly when Windows shuts down?
Mia Lopez
The host is Windows 7. I would like my virtual machine to start with Windows in the background, without the need to login to Windows and manually start it. I also hope the virtual machine can be shut down elegantly upon Windows shuts down.
Is there existing script/app that does this?
5 Answers
If you're using VMware Workstation, you could make the VM a "Shared VM" and can configure it to automatically start (in the library, right-click on "Shared VMs" and choose "Manage AutoStart VMs"). By default, Shared VMs are subjected to a hard power-off when the host is shut down. You can change this by editing %PROGRAMDATA%\VMware\hostd\vmAutoStart.xml and changing the stopAction value to GuestShutdown (or to Suspend if you'd rather suspend the VM). You will need to restart the VMware Workstation Server service after making changes to this file (and you should shut down any running shared VMs before restarting the service).
Update: In Workstation Pro 14, the context menu item is now "Manage VM Power Actions" and now supports configuring a VM to automatically suspend when the host shuts down.
2You can also use the vmrun command.
You can use a script to start a VM, for example:
vmrun -T ws start "F:\VMWare-VMs\S1.vmx"and you add the script at Windows startup.
3I'm using VMware Workstation 15.5.2 and I start my background-VMs with this command:
vmrun start "C:\VMs\D10AMP\D10AMP.vmx" noguiThe VM starts in background and no VMware window opens.
4Shared VMs are deprecated:
The Shared virtual machine feature (VMware Workstation as server) is being deprecated. It will remain in its present form for the remainder of the VMware Workstation 16 product life. This feature will be not available in a future release.
There is a workaround. You can still start them manually with task scheduler via vmrun. But I have not done that personally so I can't provide details.
Great News Update: I found a January 2021 discussion where mikeroySoft from VMware hopped in with some more details:
To be clear, it’s really just the underpinning framework that we’re using to deliver that feature that’s being deprecated. I expect we’ll have a new way to ‘autostart VMs’ in the future.
The shared vm feature uses this huge component from ESXi that has sort of run its course when ported to our stack. (Hostd for those curious...) but we are looking to implement this without hostd in the future.
So the answer is: The current feature will be removed in VMware Workstation 17. Luckily, they are looking for ways to implement auto-start VMs another way after that "Shared VMs" feature is removed. Hopefully the new method is ready immediately when version 17 launches.
Thanks for scotty86's method, I just provide a more elegent method with VBS, which won't open a cmd window when the command running.
Save the following code as vmrun.vbs in startup folder.
Set oShell = CreateObject ("Wscript.Shell")
Dim cmdStrs : cmdStrs = Array( _ """C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"" start ""C:\Virtual Machines\Debian_10_01\Debian_10_01.vmx"" nogui", _ """C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"" start ""C:\Virtual Machines\Debian_10_02\Debian_10_02.vmx"" nogui" _
)
For Each cmdStr In cmdStrs oShell.Run cmdStr, 0, false
Next 1