BAT检查VM虚拟机是否启动
@echo off
rem 虚拟机安装目录
set"vmPath=D:\Program Files (x86)\VMware\VMware Workstation"
rem 虚拟机vmx文件地址
set "vmxPath=D:\Virtual Machines\Windows Server 2019\Windows Server 2019.vmx"
cd /d "%vmPath%"
vmrun.exe list | findstr /I "%vmxPath%" >nul && echo 虚拟机已启动 || (
echo 正在启动虚拟机%vmxPath%
vmrun.exe -T ws start "%vmxPath%" nogui && echo 虚拟机成功启动 || echo 虚拟机启动失败
)
pause
写的好,真不错
页:
[1]