设置VMWare虚拟机以及网络开关批处理
程序员文章站
2022-07-07 12:18:14
这篇文章主要介绍了设置VMWare虚拟机以及网络开关批处理,示例环境基于Windows系统,需要的朋友可以参考下... 15-07-06...
由于vm虚拟机的网络连接造成服务器不能正常启动,所以把网络连接禁用了.但每次使用vm步骤会很繁琐.所以做了个批处理.
启动:
复制代码
代码如下:<p>:启动,打印命令
@echo on
net start vmnetdhcp
net start "vmware nat service"
:启用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=enabled
netsh interface set interface name="vmware network adapter vmnet8" admin=enabled
:启动程序
"d:/program files/vmware/vmware.exe"
:暂停
pause
</p>
@echo on
net start vmnetdhcp
net start "vmware nat service"
:启用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=enabled
netsh interface set interface name="vmware network adapter vmnet8" admin=enabled
:启动程序
"d:/program files/vmware/vmware.exe"
:暂停
pause
</p>
复制代码
代码如下:<p>:启动,打印命令
@echo on
net start vmnetdhcp
net start "vmware nat service"
:启用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=enabled
netsh interface set interface name="vmware network adapter vmnet8" admin=enabled
:启动程序
"d:/program files/vmware/vmware.exe"
:暂停
pause
</p>
@echo on
net start vmnetdhcp
net start "vmware nat service"
:启用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=enabled
netsh interface set interface name="vmware network adapter vmnet8" admin=enabled
:启动程序
"d:/program files/vmware/vmware.exe"
:暂停
pause
</p>
停止
复制代码
代码如下:<p>:停止服务
@echo on
net stop vmnetdhcp
net stop "vmware nat service"
:禁用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=disabled
netsh interface set interface name="vmware network adapter vmnet8" admin=disabled
:强杀进程
taskkill /f /im vmware-tray.exe
:暂停
pause
</p>
@echo on
net stop vmnetdhcp
net stop "vmware nat service"
:禁用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=disabled
netsh interface set interface name="vmware network adapter vmnet8" admin=disabled
:强杀进程
taskkill /f /im vmware-tray.exe
:暂停
pause
</p>
复制代码
代码如下:<p>:停止服务
@echo on
net stop vmnetdhcp
net stop "vmware nat service"
:禁用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=disabled
netsh interface set interface name="vmware network adapter vmnet8" admin=disabled
:强杀进程
taskkill /f /im vmware-tray.exe
:暂停
pause
</p>
@echo on
net stop vmnetdhcp
net stop "vmware nat service"
:禁用网络连接
netsh interface set interface name="vmware network adapter vmnet1" admin=disabled
netsh interface set interface name="vmware network adapter vmnet8" admin=disabled
:强杀进程
taskkill /f /im vmware-tray.exe
:暂停
pause
</p>
以下是更加方便的
安装vm后发现默认服务是启动的,但并不是每次动用到vm,为了优化系统,可以考虑按需启动服务,但每次手工启动好几个相关的服务的确比较麻烦。可以考虑采用批处理的方式来解决启动、停止的问题:
@ echo off
title vmware服务开启、关闭程序
set in=set /p in=1.开启vm服务,2.关闭vm服务。请输入:
复制代码
代码如下:if "%in%"=="1" goto start
if "%in%"=="2" goto stop
exit
:start
net start ufad-ws60
net start vmauthdservice
net start vmnetdhcp
net start "vmware nat service"
net start vmusbarbservicepause
exit
:stop
net stop ufad-ws60
net stop vmauthdservice
net stop vmnetdhcp
net stop "vmware nat service"
net stop vmusbarbservice
pause
exit
if "%in%"=="2" goto stop
exit
:start
net start ufad-ws60
net start vmauthdservice
net start vmnetdhcp
net start "vmware nat service"
net start vmusbarbservicepause
exit
:stop
net stop ufad-ws60
net stop vmauthdservice
net stop vmnetdhcp
net stop "vmware nat service"
net stop vmusbarbservice
pause
exit
或者如下:
复制代码
代码如下:echo off
title switch %date% %time%
:a
color a
cls
echo ++++++++++++++++++++++++++++++++++++++++++++++++
echo = welcome to vmware switch =
echo. = =
echo = 启动= 1 关闭= 2 设置手动= 3 退出= 4 =
echo. = =
echo. = =
echo ++++++++++++++++++++++++++++++++++++++++++++++++
echo.
echo.
set session=""
set /p session= select[1/2/3/4]:
if /i "%session%"=="1" (goto:1)
if /i "%session%"=="2" (goto:2)
if /i "%session%"=="3" (goto:3)
if /i "%session%"=="4" (goto:4)</p> <p>:1
echo "正在启动vmware相关开机服务..."
net start vmauthdservice
net start vmnetdhcp
net start "vmware nat service"
net start vmusbarbservice
echo 服务启动完毕!
ping 127.0.0.1 /n 2 >nul
goto:a</p> <p>:2
echo "正在关闭vmware相关开机服务..."
net stop vmauthdservice
net stop vmnetdhcp
net stop "vmware nat service"
net stop vmusbarbservice
echo 服务已关闭!
ping 127.0.0.1 /n 2 >nul
goto:a</p> <p>:3
echo 切换vmware开机启动服务为手动中,请稍候...
sc config vmauthdservice start= demand
sc config vmnetdhcp start= demand
sc config "vmware nat service" start= demand
sc config vmusbarbservice start= demand
echo 成功切换为手动模式!
ping 127.0.0.1 /n 2 >nul
goto:a</p> <p>:4
cls
echo 谢谢使用...
ping 127.0.0.1 /n 2 >nul
exit
title switch %date% %time%
:a
color a
cls
echo ++++++++++++++++++++++++++++++++++++++++++++++++
echo = welcome to vmware switch =
echo. = =
echo = 启动= 1 关闭= 2 设置手动= 3 退出= 4 =
echo. = =
echo. = =
echo ++++++++++++++++++++++++++++++++++++++++++++++++
echo.
echo.
set session=""
set /p session= select[1/2/3/4]:
if /i "%session%"=="1" (goto:1)
if /i "%session%"=="2" (goto:2)
if /i "%session%"=="3" (goto:3)
if /i "%session%"=="4" (goto:4)</p> <p>:1
echo "正在启动vmware相关开机服务..."
net start vmauthdservice
net start vmnetdhcp
net start "vmware nat service"
net start vmusbarbservice
echo 服务启动完毕!
ping 127.0.0.1 /n 2 >nul
goto:a</p> <p>:2
echo "正在关闭vmware相关开机服务..."
net stop vmauthdservice
net stop vmnetdhcp
net stop "vmware nat service"
net stop vmusbarbservice
echo 服务已关闭!
ping 127.0.0.1 /n 2 >nul
goto:a</p> <p>:3
echo 切换vmware开机启动服务为手动中,请稍候...
sc config vmauthdservice start= demand
sc config vmnetdhcp start= demand
sc config "vmware nat service" start= demand
sc config vmusbarbservice start= demand
echo 成功切换为手动模式!
ping 127.0.0.1 /n 2 >nul
goto:a</p> <p>:4
cls
echo 谢谢使用...
ping 127.0.0.1 /n 2 >nul
exit
另外,如果安装vm之后,开机时按一下用户名才能登录桌面的解决方法:
1运行框中输入netplwiz
2取消 "要使用本机,用户必须输入用户名和密码" 前面的勾
上一篇: Nginx-日志切割