1.运行-services.msc,找到VMware开头的(一般为5个)-双击打开-修改启动类型为手动
2.编辑Windows批处理文件
新建一个文本文档-把扩展名改成.bat
@echo off
for /f "skip=3 tokens=4" %%i in ('sc query "VMAuthdService"') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
echo 服务VMware Authorization Service正在运行
) else (
echo 服务VMware Authorization Service已停止
)
for /f "skip=3 tokens=4" %%i in ('sc query "VMnetDHCP"') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
echo 服务VMware DHCP Service正在运行
) else (
echo 服务VMware DHCP Service已停止
)
for /f "skip=3 tokens=4" %%i in ('sc query "VMware NAT Service"') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
echo 服务VMware NAT Service正在运行
) else (
echo 服务VMware NAT Service已停止
)
for /f "skip=3 tokens=4" %%i in ('sc query "VMUSBArbService"') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
echo 服务VMware USB Arbitration Service正在运行
) else (
echo 服务VMware USB Arbitration Service已停止
)
for /f "skip=3 tokens=4" %%i in ('sc query "VMwareHostd"') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="RUNNING" (
echo 服务VMware Workstation Server正在运行
) else (
echo 服务VMware Workstation Server已停止
)
choice /c:12 /m "启动/停止VM虚拟机服务及网络连接[1启动,2停止]"
if errorlevel 2 goto two
if errorlevel 1 goto one
:one
echo 正在启用服务...
net start "VMnetDHCP"
net start "VMware NAT Service"
net start "VMUSBArbService"
net start "VMAuthdService"
net start "VMwareHostd"
echo 正在启用网络连接...
netsh interface set interface "VMware Network Adapter VMnet1" enable
netsh interface set interface "VMware Network Adapter VMnet8" enable
echo 网络连接VMware Network Adapter VMnet1、VMware Network Adapter VMnet8启动成功
choice /c:12 /m " 是否启动VMware Workstations...[1是,2否]"
if errorlevel 2 exit
if errorlevel 1 start "" "D:\VMware\VMware14\Install"
>nul
:two
echo 正在禁用服务服务...
net stop "VMwareHostd"
net stop "VMnetDHCP"
net stop "VMware NAT Service"
net stop "VMUSBArbService"
net stop "VMAuthdService"
echo 正在禁用网络连接...
netsh interface set interface "VMware Network Adapter VMnet1" disable
netsh interface set interface "VMware Network Adapter VMnet8" disable
echo 网络连接VMware Network Adapter VMnet1、VMware Network Adapter VMnet8禁用成功
echo 按任意键退出...
pause>nul
exit
3.运行批处理文件,右键-以管理员身份运行-按提示选择功能
4.关闭图标,打开VMware Workstations-编辑-首选项-工作区-显示托盘图标-修改为从不
完成
下次需要用VMware的时候,以管理员身份运行批处理文件,按提示启动服务并运行程序即可。
注意:
- 需要修改 .bat 文件中 if errorlevel 1 start "" "D:\VMware\VMware14\Install" vmware 安装位置
-
批处理文件需要用管理员身份运行,否则会出错
-
关闭服务时提示的系统错误1067属正常情况,不用理会
-
不想每次右键管理员的请自行查找相关经验