@ECHO OFF
CLS
color 0a
:menu
cls
echo.
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo             请选择要进行的操作，然后按回车
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo               1、bridge（桥接）相关设置
echo.
echo               2、usb 相关设置
echo.
echo               3、nat（网络共享）相关设置
echo.
echo               4、host-only（本地网络）相关设置
echo.
echo               5、VMnetDHCP和vmnat相关设置（高级用户）
echo.
echo               6、磁盘碎片整理、映射（可选功能）
echo.
echo               7、退出
:cho
echo.
set /p choice=  请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto s1
if /i "%choice%"=="2" goto s2
if /i "%choice%"=="3" goto s3
if /i "%choice%"=="4" goto s4
if /i "%choice%"=="5" goto s5
if /i "%choice%"=="6" goto s6
if /i "%choice%"=="7" goto end
echo 选择无效，请重新输入
echo.
goto cho
@echo off

:s1
cls
echo.
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo             请选择要进行的操作，然后按回车
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo               1、禁用桥接服务
echo.
echo               2、启用桥接服务
echo.
echo               3、返回主目录
echo.
echo               4、退出

:chos1
set /p choice=          请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto s11
if /i "%choice%"=="2" goto s12
if /i "%choice%"=="3" goto menu
if /i "%choice%"=="4" goto end
echo 选择无效,请重新输入!
:s11
net stop VMnetBridge
sc delete VMnetBridge
"%cd%\bridgeinstall.exe" -u vmware_bridge
pause >nul
goto s1
:s12
"%cd%\bridgeinstall.exe" -l netbridge.inf -i vmware_bridge
net start VMnetBridge
pause >nul
goto s1

:s2
cls
echo.
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo             请选择要进行的操作，然后按回车
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo               1、禁用USB服务
echo.
echo               2、启动USB服务
echo.
echo               3、返回主目录
echo.
echo               4、退出

:chos2
set /p choice=          请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto s21
if /i "%choice%"=="2" goto s22
if /i "%choice%"=="3" goto menu
if /i "%choice%"=="4" goto end
echo 选择无效,请重新输入!
:s21
net stop hcmon
net stop vmusb
sc delete hcmon
sc delete vmusb
pause >nul
goto s2
pause >nul
goto s2
:s22

sc create hcmon type= kernel start= auto binpath= "%cd%\hcmon.sys" displayname= "VMware hcmon"
net start hcmon
pause >nul
goto s2

:s3
cls
echo.
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo             请选择要进行的操作，然后按回车
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo               1、禁用nat服务
echo.
echo               2、启用nat服务（默认安装虚拟网卡8）
echo.
echo               3、返回主目录
echo.
echo               4、退出

:chos3
set /p choice=          请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto s31
if /i "%choice%"=="2" goto s32
if /i "%choice%"=="3" goto menu
if /i "%choice%"=="4" goto end
echo 选择无效,请重新输入!
:s31
start /wait vnetlib -- remove adapter vmnet8
echo nat成功禁用。。。
pause >nul
goto s3
:s32
start /wait vnetlib -- add adapter vmnet8
start /wait vnetlib -- add dhcp vmnet8
start /wait vnetlib -- add nat vmnet8
start /wait vnetlib -- set vnet vmnet8 addr 192.168.128.0
start /wait vnetlib -- stop nat
start /wait vnetlib -- stop dhcp
start /wait vnetlib -- update dhcp vmnet8
start /wait vnetlib -- start dhcp
start /wait vnetlib -- update nat vmnet8
start /wait vnetlib -- start nat
start /wait vnetlib -- update adapter vmnet8
set regadd=reg add "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMnetLib\VMnetConfig\vmnet8\NAT
%regadd%" /v AllowAnyOUI /t REG_DWORD /d 1 /f >nul 2>nul
echo nat启动成功。。。
pause >nul
goto s3

:s4
cls
echo.
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo             请选择要进行的操作，然后按回车
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo               1、禁用host-only服务
echo.
echo               2、启用host-only服务（默认安装虚拟网卡1）
echo.
echo               3、返回主目录
echo.
echo               4、退出

:chos4
set /p choice=          请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto s41
if /i "%choice%"=="2" goto s42
if /i "%choice%"=="3" goto menu
if /i "%choice%"=="4" goto end
echo 选择无效,请重新输入!
:s41
start /wait vnetlib -- remove adapter vmnet1
echo host-only成功禁用。。。
pause >nul
goto s4
:s42
start /wait vnetlib -- add adapter vmnet1
start /wait vnetlib -- add dhcp vmnet1
start /wait vnetlib -- set vnet vmnet1 addr 10.10.10.0
start /wait vnetlib -- stop dhcp
start /wait vnetlib -- update dhcp vmnet1
start /wait vnetlib -- start dhcp
start /wait vnetlib -- update adapter vmnet1
echo host-only启动成功。。。
pause >nul
goto s4


:s5
cls
echo.
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo             请选择要进行的操作，然后按回车
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo               1、停止VMnetDHCP服务
echo.
echo               2、停止vmnat服务
echo.
echo               3、启动VMnetDHCP服务
echo.
echo               4、启动vmnat服务
echo.
echo               5、返回主目录
echo.
echo               6、退出

:chos5
set /p choice=          请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto s51
if /i "%choice%"=="2" goto s52
if /i "%choice%"=="3" goto s53
if /i "%choice%"=="4" goto s54
if /i "%choice%"=="5" goto menu
if /i "%choice%"=="6" goto end
echo 选择无效,请重新输入!
:s51
net stop VMnetDHCP
pause >nul
goto s5
:s52
net stop "VMware NAT Service"
pause >nul
goto s5
:s53
net start VMnetDHCP
pause >nul
goto s5
:s54
net start "VMware NAT Service"
pause >nul
goto s5

:s6
cls
echo.
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo             请选择要进行的操作，然后按回车
echo             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo               1、禁用“编辑虚拟机设置”中硬盘的“工具=》磁盘碎片整理、映射功能”
echo.
echo               2、启用“编辑虚拟机设置”中硬盘的“工具=》磁盘碎片整理、映射功能”
echo.
echo               3、返回主目录
echo.
echo               4、退出

:chos6
set /p choice=          请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto s61
if /i "%choice%"=="2" goto s62
if /i "%choice%"=="3" goto menu
if /i "%choice%"=="4" goto end
echo 选择无效,请重新输入!
:s61
net stop vstor2-ws60
sc delete vstor2-ws60
"%cd%\bridgeinstall.exe" -u vmware_bridge
pause >nul
goto s6
:s62
sc create vstor2-ws60 type= "kernel" start= "auto" binpath= "%CD%\vstor2-ws60.sys"  displayname= "Vstor2 WS60 Virtual Storage Driver" 
net start vstor2-ws60
pause >nul
goto s6

:end
exit