@echo off
cls
color 0a
echo.
echo               VMware workstation-7.0.0-203739 绿色精简版
echo.
echo.
echo                                 即将进行安装，是否要继续......
echo.     
echo ---------------------------------------------------------------------------
echo.
SET /P ST=   请输入 Y (继续安装)或 N (退出安装)：
echo.
if /I "%ST%"=="Y" goto ST
if /I "%ST%"=="N" goto EX
goto EX

:ST
copy /y vmusb.cat %systemroot%\inf\vmusb.cat
copy /y vmusb.inf %systemroot%\inf\vmusb.inf
copy /y vmusb.sys %systemroot%\inf\vmusb.sys
copy /y vmusb.sys %systemroot%\inf\VMUSB.PNF
copy /y vmusb.sys %systemroot%\system32\drivers\vmusb.sys
:regdll
regsvr32 /s vmappcfg.dll
regsvr32 /s vmappsdk.dll
regsvr32 /s vmdbCOM.dll

:addreg
echo 正在添加注册表项目...
reg delete  "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc." /f >nul 2>nul
set regadd=reg add "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.
%regadd%" /v Core /d "VMware Workstation" /f
set regadd=%regadd%\VMware Workstation
%regadd%" /v "InstallPath" /d "%cd%" /f
set regadd=reg add "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Player
%regadd%" /v "InstallPath" /d "%cd%" /f

reg import vm.reg

reg import Player.reg



:adduser
echo 开始创建 __vmware_user__ 账户 ... 
net user __vmware_user__ /add >nul
net localgroup __vmware__ /add >nul
net localgroup users __vmware_user__ /del >nul
net localgroup __vmware__ __vmware_user__ /add >nul

:Start VM basic service
echo 装载虚拟机需要基本服务 ... 
sc create vmci type= kernel start= auto binpath= "%cd%\vmci.sys" displayname= "VMware vmci" group= "Extended base"
net start vmci

sc create vmx86 type= kernel start= auto binpath= "%cd%\vmx86.sys" displayname= "VMware Virtualization Driver" 
net start vmx86

sc create VMnetuserif type= kernel start= auto binpath= "%cd%\vmnetuserif.sys" displayname= "VMware Network Application Interface"
net start VMnetuserif

sc create VMnetDHCP binpath= "%cd%\VMnetDHCP.exe"  depend= "VMnetuserif" displayname= "VMware DHCP Service"
set regadd=reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMnetDHCP\Parameters
%regadd%" /v "ConfFile" /d "%cd%\vmnetdhcp.conf" /f
%regadd%" /v "LeaseFile" /d "%cd%\vmnetdhcp.leases" /f

sc create "VMware NAT Service" binpath= "%cd%\vmnat.exe"  depend= "VMnetuserif" displayname= "VMware NAT Service"
set regadd=reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMware NAT Service\Parameters
%regadd%" /v "ConfigPath" /d "%cd%" /f

call server.cmd