Is it possible to autostart a VMware virtual machine in background as a Windows service, and shut it down elegantly when Windows shuts down?

10

4

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?

bfrguci

Posted 2016-02-19T05:11:28.757

Reputation: 403

Answers

18

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.

jamesdlin

Posted 2016-02-19T05:11:28.757

Reputation: 1 973

1This worked for me. – Jason – 2016-12-15T09:45:04.677

Ugh... that is second time I overlooked something in Library | Rt-click. Too bad it's not somewhere in the VM instance's settings. – Peter L – 2019-11-19T22:54:28.563

12

You 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.

More info about vmrun: http://www.sysadmit.com/2016/11/vmware-workstation-vmrun.html

Roderick Decker

Posted 2016-02-19T05:11:28.757

Reputation: 121

Easy and nice ! just put the vmrun,exe location in the path (for windows) and put this command in a bat file and call the bat file at startup – Nassim – 2018-05-04T06:59:24.417

This is a better alternative if you require certian features that using share VMs disabled (like shared folders!) – ecnepsnai – 2018-09-18T05:19:37.993

FYI, if your virtual machine used physical disks that require Administrative privilege with vmrun, use Task Scheduler to create a task with highest privileges. – ttimasdf – 2019-11-20T15:07:06.997