Both VMWare ESXi and VMWare Workstation don’t automatically start virtual machines by default. This means that the administrator must manually start all virtual machines after the ESXi/Workstation host reboots (due to a scheduled reboot or crash). This guide shows how to enable autostart VMs on VMWare ESXi or Workstation host.
Table of Contents
How to Configure Automatic Startup of VMs on VMware ESXi
The settings for the VM auto-start are different depending on whether your ESXi host is connected to vCenter VCSA or not.
For a standalone VMware ESXi 8.0 host:
- Open the browser and sign-in ESXi Host Client web UI;
- Select Manage > System > Autostart;
- Automatic VM startup is disabled by default;
- Select the VM in the list and click Enable if you want it to start it automatically;
- Use the Start later and Start earlier buttons to configure the order in which VMs start on ESXi host. The virtual machine with the Autostart order value of 1 will start first, and so on.
This feature allows you to set the correct order in which virtual machines will boot up. For example, the domain controller should be booted first, followed by the Exchange server, or the application server should be booted after the MSSQL VM is booted,
You can set advanced startup and shutdown settings for VMs by clicking the Configure button. Available options:
- Startup delay — how many seconds VMs wait before powering on (by default it’s 120 seconds). After the ESXi host powers on the first VM, the host waits for the specified delay before powering on the next virtual machine. This delay allows you to wait for booting of custom services and scripts execution;
- Shutdown delay — specifies the delay to wait before shutting down each virtual machine (by default it’s 120 seconds). If the virtual machine does not shut down within the specified delay time, a hard shutdown command is sent to the virtual machine;
- Stop Action — four VM shutdown actions are available: System default, Shut Down, Suspend, or Power off. This feature relies on VMware Tools, which must be preinstalled in the guest OS. Default action is Shut down.
- Wait for heartbeat — if enabled, the boot sequence continues after the ESXi host receives the first heartbeat from the VM (also requires VMWare tools). This feature allows VMs to boot in a specific order without waiting for a startup delay interval.
The following Stop Actions are available:
- System Default — global Stop Action settings are applied to all VMs by default. ( from Host > Manage > Autostart);
- Power Off — forced shutdown of VM. This is the equivalent of physically unplugging the power cord from a physical computer. This action kills the VM immediately, with no graceful stopping of services, saving of files or cache;
- Suspend — the state of the running virtual machine (including memory, swap, CPU instructions) is saved on your datastore. The VM can later be resumed from sleeping at exactly the same point;
- Shutdown — performs a graceful VM shutdown (the shutdown command is sent from ESXi to the guest operating system via VMTools).
You can configure global autostart settings that will be applied to all new VMs on the ESXi host. To do this, click the Edit Settings button at the top of the Autostart dialog box.
To enable autostart for all VMs, change the Enabled to Yes, then configure default start/stop delay and stop action.
Tip. If your ESXi host is managed by the vCenter Server and is a part of the vSphere HA cluster, you can’t configure VM autostart and shutdown settings this way. This happens because the HA cluster is responding to help keep VMs up and running.
Configure VMs Autostart using PowerShell
You can configure VM autostart settings on ESXi/vCenter using PowerShell. This requires the PowerCLI module to be installed on the administrator’s machine.
Connect to ESXi host or vCenter using the command:
connect-viserver -server yourESXihost
Check the current startup settings for all VMs on the host:
Get-VM | Get-VMStartPolicy
To enable autostart for a specific VM, run the following commands:
Get-VMHostStartPolicy | Set-VMHostStartPolicy -Enabled $true
Get-VM hq-dc01 | Get-VMStartPolicy | Set-VMStartpolicy -StartAction PowerOn -StartOrder 2 -StartDelay 300 -StopAction GuestShutDown -StopDelay 300
Also, you can enable autostart manager from the ESXi shell. Connect to ESXi via SSH and run the command:
# vim-cmd hostsvc/autostartmanager/enable_autostart 1
Get VMs startup settings:
# vim-cmd hostsvc/autostartmanager/get_autostartseq
How to Start Virtual Machines Automatically on VMware Workstation
The VMware Workstation desktop virtualization app doesn’t provide options to automatically start virtual machines when Windows boots. However, you can use the built-in vmrun.exe command line tool in your scripts and scheduled tasks to automatically start specific VMs.
You can run any virtual machine by creating the following batch file AutoStartVM.bat.
start “C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe” start “D:\VM\TestVm1\TestVm1.vmx”
ping 127.0.0.1 -n 40 > nul
start “C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe” start “D:\VM\freebsd2\freebsd2.vmx”
The second line of code is used to create a 40 second delay before the second VM starts. You can copy this file to the desktop (and run it manually by double-clicking it), add it to the Windows Startup, or run it through the Task Scheduler job.
Starting with VMware Workstation Pro 17.0, you can use the GUI to configure the autostart of VMs.
- Open the services.msc console and change the startup type to Automatic for the VMware Autostart Service;
- Launch VMware Workstation Pro;
- Right-click My Computer > Configure Auto Start VMs;
- Select VMs what you want to start automatically and set startup order.