Windows Service plus WPF control panel for a Windows 11 host. The service can start the VMware XP virtual machine in KVM mode, watches a serial CTS signal and shuts down the VM before shutting down the host. The GUI configures the controller, installs/removes the service, starts/stops it and shows service/CTS status.
Default setup:
- COM port:
COM3 - VMware Workstation tools are expected in the default path:
C:\Program Files (x86)\VMware\VMware Workstation - VMX file: select the target
.vmxfile in the GUI for each deployment. - Soft stop timeout:
60seconds - Hard stop timeout:
30seconds - Block CTS shutdown: enabled by default
Startup sequence:
- Windows Service starts.
- If enabled, the service waits for an active user session.
- The service runs
vmware-kvm.exe "<vmx>"in that interactive session. - The service opens the configured COM port and monitors CTS.
Shutdown sequence:
- CTS changes to ON.
- If
Block CTS shutdownis enabled, CTS is logged and no shutdown is started. - The app waits for the debounce time.
- The app runs
vmrun stop "<vmx>" soft. - If
vmrunhangs, the app kills thatvmrunprocess after the soft timeout. - If the VM is still listed by
vmrun list, the app runsvmrun stop "<vmx>" hard. - If enabled, the app schedules
shutdown.exe /sfor the host.
Settings, logs and runtime status are stored in the same folder as SerialVmPowerController.exe:
settings.xml
log.txt
runtime-status.xml
Copy the whole Service folder to the final PC and run the application from that folder. With UWF enabled, commit this folder or add an exclusion if settings and logs must survive restarts.
Run SerialVmPowerController.exe normally to open the GUI.
From the GUI, run as administrator and use:
Install serviceto register the current executable asSerialVmPowerController.Startto start the Windows Service.Stopto stop the Windows Service.Uninstallto remove the service.
The service executable path is installed as:
SerialVmPowerController.exe --service
Important VMware note: the service is installed under the default Windows service account. On VMware Workstation/KVM setups, test that vmrun.exe launched from the service can see and control the same VM that runs in the interactive user session. Any failure is written to log.txt.
KVM startup note: vmware-kvm.exe is an interactive desktop application. The service starts it in the active console user's session, not in hidden Session 0. Automatic Windows logon should be enabled on the panel if the VM must appear immediately after boot.
Use Visual Studio 2022 or MSBuild:
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" .\SerialVmPowerController.sln /p:Configuration=ReleaseThe Release build also creates SerialVmPowerController.xml next to the executable. Visual Studio uses this file for IntelliSense/reference documentation.
Create the portable deployment folder:
.\Create-ServiceFolder.ps1The script resolves the git repository root, builds Release and copies the runtime files plus README.md into Service in the repository root.