Automatically Start and Stop a VMware Workstation VM with Windows Boot and Shutdown
If you run a VM in VMware Workstation as a background server — a dev box, a build server, a lab appliance — clicking “Power On” every time you boot your host gets old fast. And if you forget to shut it down properly before you power off Windows, you risk an unclean guest shutdown.
This guide covers both directions:
- Start the VM headlessly the moment Windows boots (or you log in), with no console window popping up.
- Stop the VM gracefully the moment Windows begins shutting down.
Both use vmrun, VMware’s command-line control tool that ships with Workstation — no third-party software required.
Prerequisites
- VMware Workstation Pro installed, with
vmrun.exepresent (usually underC:\Program Files\VMware\VMware Workstation\or the(x86)variant, depending on your install). - VMware Tools installed and running in the guest OS. This is required for a graceful (“soft”) shutdown to work — without it, VMware can’t ask the guest to shut down cleanly.
- The full path to your VM’s
.vmxfile. You can find it with:dir "C:\path\to\your\vm\*.vmx"
Throughout this guide, the examples use:
vmrun.exe: C:\Program Files\VMware\VMware Workstation\vmrun.exe
VM file: C:\Virtual Machines\Ubuntu 24.04\Ubuntu 24.04.vmx
Swap in your own paths.
Part 1: Auto-Start the VM at Windows Boot
The command
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws start "C:\Virtual Machines\Ubuntu 24.04\Ubuntu 24.04.vmx" nogui
The nogui flag is the key part — it starts the VM entirely in the background. No Workstation window, no console tab, nothing to click through. You just SSH or RDP into the guest once it’s up.
Wrap it in a batch file
Save this as start-xubuntu.bat:
@echo off
set VMRUN="C:\Program Files\VMware\VMware Workstation\vmrun.exe"
set VMX="C:\Virtual Machines\Ubuntu 24.04\Ubuntu 24.04.vmx"
%VMRUN% -T ws start %VMX% nogui
If your VM ever comes up looking paused instead of fully booted, add a follow-up line to force it:
%VMRUN% -T ws reset %VMX%
Schedule it with Task Scheduler
The Startup folder (shell:startup) works, but Task Scheduler gives you a delay option, which matters here — VMware’s background networking services (vmnet, authd) need a moment to initialize before vmrun can talk to them.
- Open Task Scheduler (Win key → search “Task Scheduler”) and click Create Basic Task…
- Name it something like Start xUbuntu VM.
- Set the trigger:
- When I log on — simplest, runs each time you sign in.
- When the computer starts — runs even before anyone logs in (requires the setting below).
- Action: Start a program → Browse to
start-xubuntu.bat. - On finish, tick “Open Properties,” and if you chose “When the computer starts,” select Run whether user is logged on or not on the General tab.
- On the Triggers tab, edit the trigger → Advanced settings → check Delay task for and set it to 30–60 seconds. This avoids race conditions with VMware’s services on boot.
- Test it by right-clicking the task and choosing Run, then confirm with:
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" list
Note: If you use “When the computer starts” + “Run whether user is logged on or not,” test with a full reboot, not just “Run” from Task Scheduler — some Workstation licensing/session behavior can differ when nothing is logged in yet.
Part 2: Auto-Stop the VM at Windows Shutdown
The command
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws stop "C:\Virtual Machines\Ubuntu 24.04\Ubuntu 24.04.vmx" soft
soft tells VMware Tools inside the guest to shut the OS down gracefully — the equivalent of running shutdown from within the guest itself, rather than yanking power.
Save this as stop-xubuntu.bat:
@echo off
"C:\Program Files\VMware\VMware Workstation\vmrun.exe" -T ws stop "C:\Virtual Machines\Ubuntu 24.04\Ubuntu 24.04.vmx" soft
Why Task Scheduler doesn’t have a simple “shutdown” trigger
Unlike startup, Windows has no built-in “run this at shutdown” checkbox in the Task Scheduler wizard. There are two supported ways to get a script to fire before the OS actually powers off:
Option A: Group Policy shutdown script (Windows 11 Pro/Enterprise)
- Press Win+R, type
gpedit.msc, Enter. (Not available on Windows 11 Home — use Option B instead.) - Navigate to Computer Configuration → Windows Settings → Scripts (Startup/Shutdown), and double-click Shutdown.
- Click Add…, browse to
stop-xubuntu.bat, and confirm. - Increase the script wait time. A Linux guest’s graceful shutdown can take well over a minute, but Windows may cut scripts off before that. Go to Computer Configuration → Administrative Templates → System → Scripts, open Specify maximum wait time for Group Policy scripts, set it to Enabled, and give it something like
120seconds. - Test by shutting down or restarting Windows normally — you’ll see a brief pause on the shutdown screen while the script runs. Check afterward that the VM shows as cleanly powered off, not suspended.
Option B: Task Scheduler with an event trigger (Windows 11 Home, or if you prefer avoiding gpedit)
Windows logs an event the moment a shutdown or restart is requested, before it actually happens — you can trigger off that.
- Open Task Scheduler → Create Task… (the full dialog, not “Create Basic Task,” since you need an event trigger).
- Triggers tab → New → “Begin the task” = On an event.
- Set Log:
System, Source:User32, Event ID:1074. - Actions tab → Start a Program → point it at
stop-xubuntu.bat. - General tab → check Run whether user is logged on or not and Run with highest privileges.
A Caveat Worth Knowing
A soft stop only works if VMware Tools is installed and responsive inside the guest. If Tools isn’t running or the guest is hung, the soft stop request does nothing — and Windows will simply kill the VM process when it shuts down anyway, the same as an unclean power-off. It won’t corrupt most workloads, but it’s not a substitute for making sure Tools is actually running.
Wrapping Up
With both pieces in place, your VM behaves like any other background service: it comes up shortly after you boot Windows and shuts down cleanly the moment you power off — no console window, no manual clicks, no half-shut-down guest left behind.