设置VMWare虚拟机以及网络开关批处理

网络安全 2021-07-04 10:19www.168986.cn网络安全知识

由于VM虚拟机的网络连接造成服务器不能正常启动,所以把网络连接禁用了.但每次使用VM步骤会很繁琐.所以做了个批处理.

启动

复制代码
代码如下:
<p>:启动,打印命令
@echo on
start vmdhcp
start "VMware NAT Service"
:启用网络连接
sh interface set interface name="VMware Network Adapter VM1" admin=ENABLED
sh interface set interface name="VMware Network Adapter VM8" admin=ENABLED
:启动程序
"D:/Program Files/VMware/vmware.exe"
:暂停
pause
</p>

 

复制代码
代码如下:
<p>:启动,打印命令
@echo on
start vmdhcp
start "VMware NAT Service"
:启用网络连接
sh interface set interface name="VMware Network Adapter VM1" admin=ENABLED
sh interface set interface name="VMware Network Adapter VM8" admin=ENABLED
:启动程序
"D:/Program Files/VMware/vmware.exe"
:暂停
pause
</p>

停止

复制代码
代码如下:
<p>:停止服务
@echo on
s vmdhcp
s "VMware NAT Service"
:禁用网络连接
sh interface set interface name="VMware Network Adapter VM1" admin=DISABLED
sh interface set interface name="VMware Network Adapter VM8" admin=DISABLED
:强杀进程
taskkill /F /im vmware-tray.exe
:暂停
pause
</p>


 

复制代码
代码如下:
<p>:停止服务
@echo on
s vmdhcp
s "VMware NAT Service"
:禁用网络连接
sh interface set interface name="VMware Network Adapter VM1" admin=DISABLED
sh interface set interface name="VMware Network Adapter VM8" 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 s
exit
:start
start ufad-ws60
start VMAuthdService
start VMDHCP
start "VMware NAT Service"
start VMUSBArbServicepause
exit
:s
s ufad-ws60
s VMAuthdService
s VMDHCP
s "VMware NAT Service"
s 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相关开机服务..."
start VMAuthdService
start VMDHCP
start "VMware NAT Service"
start VMUSBArbService
echo 服务启动完毕!
ping 127.0.0.1 /n 2 >nul
goto:A</p> <p>:2
echo "正在关闭VMware相关开机服务..."
s VMAuthdService
s VMDHCP
s "VMware NAT Service"
s VMUSBArbService
echo 服务已关闭!
ping 127.0.0.1 /n 2 >nul
goto:A</p> <p>:3
echo 切换VMware开机启动服务为手动中,请稍候...
sc config VMAuthdService start= demand
sc config VMDHCP 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运行框中输入plwiz   
2取消 "要使用本机,用户必须输入用户名和密码"  前面的勾

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by