VMware Workstation 重启服务脚本 解决连不上ssh问题

解决虚拟机,每次启动连不上ssh问题,需要关闭虚拟机,再执行脚本。执行完后,再启动虚拟机就可以连上ssh啦!

脚本名称:vmware_server_restart.bat (请以管理员身份运行,否则可能报错,本脚本在windows10系统下通过测试。) 

@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 "" "C:\Program Files (x86)\VMware\VMware Workstation\vmware.exe"
 >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 

请自己行修改脚本中VMware Workstation软件安装路径。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值