cls
@echo off
CLS
color 0a
Title VMware 8.0.4 绿色精简汉化版
set vmbit=
echo 提示:最好在安装之前,先运行一下"!)卸载VMware.cmd"文件,以免旧版本干扰新版本安装
echo.
echo 注意:
echo 运行此批处理文件后,安装过程持续十几秒钟,并将跳出VMware服务安装窗口.
echo 如果窗口一闪而过,说明安装过程中出了错误.
echo 未正确安装VMware将导致虚拟机运行出错.
echo 请先排除故障后再次运行"!)安装VMware.cmd"批处理文件进行安装.
echo.
echo 按任意键继续安装VMware&pause>nul
reg query "HKLM\SOFTWARE\VMware, Inc." >nul 2>nul || reg query "HKLM\SOFTWARE\Wow6432Node\VMware, Inc." >nul 2>nul&&(echo.&echo  系统中已经安装了VMware,请先卸载干净并重启电脑!!!&pause>nul&exit)
cls
ver|find "5.">nul && (net user %USERNAME% | find "Administrators" || call :prompt)
ver|find "6.">nul && (if "%USERNAME%" neq "Administrator" call :prompt)
echo 正在安装VMware 8.0.4 绿色精简汉化版,请稍后...

rd /s /q "%AllUsersProfile%\VMware" >nul 2>nul
rd /s /q "%AllUsersProfile%\Application Data\VMware" >nul 2>nul
rd /s /q "%AppData%\VMware" >nul 2>nul||del /f /s /q "%AppData%\VMware" >nul 2>nul
ver|find "6.">nul && (set profilepath=%AllUsersProfile%)
ver|find "5.">nul && (set profilepath=%AllUsersProfile%\Application Data)
md "%AppData%\VMware" >nul 2>nul
if %errorlevel% neq 0 echo 创建目录失败,请关闭杀毒软件或者HIPS后再重新安装VMware&pause>nul&exit
md "%profilepath%\VMware" >nul 2>nul
md "%profilepath%\VMware\VMware Workstation" >nul 2>nul
md "%profilepath%\VMware\VMware Player" >nul 2>nul
md "%profilepath%\VMware\VMware USB Arbitration Service" >nul 2>nul
if "%PROCESSOR_ARCHITECTURE%" neq "x86" goto _64
goto _86

:_64
set vmbit=64
if not exist "%cd%\64Drv" (echo.&echo  64Drv文件夹不存在或者已被删除,安装文件不全,请下载完整版!!!&pause>nul&exit)
echo 添加注册表项目...
regedit /s "%cd%\vm64.reg"
reg query "HKLM\SOFTWARE\Wow6432Node\VMware, Inc.\Installer" >nul 2>nul||(echo.&echo 注册表文件vm64.reg导入失败,请关闭杀毒软件或者HIPS后再重新安装VMware&rd /s /q "%AppData%\VMware"&rd /s /q "%profilepath%\VMware"&pause>nul&exit)
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\Installer\VMware Workstation\Features" /v core /t REG_SZ /d "%cd%" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player" /v InstallPath /t REG_SZ /d "%cd%\\" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player" /v InstallPath64 /t REG_SZ /d "%cd%\x64\\" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation" /v InstallPath /t REG_SZ /d "%cd%\\" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation" /v InstallPath64 /t REG_SZ /d "%cd%\x64\\" /f

copy /y vnetlib64.dll "%WinDir%\System32\" >nul 2>nul
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{4B6C7001-C7D6-3710-913E-5BC23FCE91E6} >nul 2>nul||(echo.&echo 正在安装VC++2008......&start /wait vc08x64.exe /q&&start /wait vc08x86.exe /q)
copy /y 64Drv\*.* >nul
copy /y 64Drv\SysWOW64\vstor2-mntapi10-shared.sys "%WinDir%\SysWOW64\Drivers\" >nul
copy /y mfc71*.dll "%WinDir%\SysWOW64\" >nul 2>nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | find "Windows 7" >nul 2>nul && copy /y 64Drv\bridge\vmnetbridge.cat4 ".\vmnetbridge.cat" >nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | find "Windows 7" >nul 2>nul && copy /y 64Drv\bridge\vmnetbridge.dll4 ".\vmnetbridge.dll" >nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | find "Windows 7" >nul 2>nul && copy /y 64Drv\bridge\vmnetbridge.sys4 ".\vmnetbridge.sys" >nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | find "Windows 7" >nul 2>nul || copy /y 64Drv\bridge\vmnetbridge.cat2 ".\vmnetbridge.cat" >nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | find "Windows 7" >nul 2>nul || copy /y 64Drv\bridge\vmnetBridge.dll1 ".\vmnetbridge.dll" >nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | find "Windows 7" >nul 2>nul || copy /y 64Drv\bridge\vmnetbridge.sys2 ".\vmnetbridge.sys" >nul

echo.
goto install

:_86
if not exist "%cd%\86Drv" (echo.&echo  86Drv文件夹不存在或者已被删除,安装文件不全,请下载完整版!!!&pause>nul&exit)
echo 添加注册表项目...
regedit /s "%cd%\vm86.reg"
reg query "HKLM\SOFTWARE\VMware, Inc.\Installer" >nul 2>nul||(echo.&echo 注册表文件vm86.reg导入失败,请关闭杀毒软件或者HIPS后再重新安装VMware&rd /s /q "%AppData%\VMware"&rd /s /q "%profilepath%\VMware"&pause>nul&exit)
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\Installer\VMware Workstation\Features" /v core /t REG_SZ /d "%cd%" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Player" /v InstallPath /t REG_SZ /d "%cd%\\" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Workstation" /v InstallPath /t REG_SZ /d "%cd%\\" /f

copy /y vnetlib.dll "%WinDir%\System32\" >nul 2>nul
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1F1C2DFC-2D24-3E06-BCB8-725134ADF989} >nul 2>nul||reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{86CE1746-9EFF-3C9C-8755-81EA8903AC34} >nul 2>nul||(echo.&echo 正在安装VC++2008......&vc08x86.exe /q)

copy /y 86Drv\*.* >nul
copy /y mfc71*.dll "%WinDir%\System32\" >nul 2>nul
ver|find "6.">nul && (copy /y 86Drv\bridge\vmnetBridge.sys3 .\vmnetBridge.sys >nul)
ver|find "5.1">nul && (copy /y 86Drv\bridge\vmnetBridge.sys1 .\vmnetBridge.sys >nul)
ver|find "5.2">nul && (copy /y 86Drv\bridge\vmnetBridge.sys1 .\vmnetBridge.sys >nul)
ver|find "6.">nul && (copy /y 86Drv\bridge\vmnetBridge.cat3 .\vmnetBridge.cat >nul)
ver|find "5.1">nul && (copy /y 86Drv\bridge\vmnetBridge.cat1 .\vmnetBridge.cat >nul)
ver|find "5.2">nul && (copy /y 86Drv\bridge\vmnetBridge.cat .\ >nul)
ver|find "6.">nul && (copy /y 86Drv\bridge\vmnetBridge.dll3 .\vmnetBridge.dll >nul)
ver|find "5.1">nul && (copy /y 86Drv\bridge\vmnetBridge.dll2 .\vmnetBridge.dll >nul)
ver|find "5.2">nul && (copy /y 86Drv\bridge\vmnetBridge.dll .\ >nul)

echo.

:install
str.exe preferences.ini 0 0 /R /asc:"VMwareDir" /asc:"%cd%" /A >nul 2>nul
str.exe environments.xml 0 0 /R /asc:"VMwareDir" /asc:"%cd%" /A >nul 2>nul
echo 复制文件...
echo.
md "%WinDir%\inf\VMware" >nul 2>nul
md "%WinDir%\inf\VMware\0009" >nul 2>nul
copy /y preferences.ini "%AppData%\VMware\" >nul 2>nul
copy /y inventory.vmls "%AppData%\VMware\" >nul 2>nul
copy /y vmconfig.ini "%profilepath%\VMware\VMware Workstation\config.ini" >nul 2>nul
copy /y settings.ini "%profilepath%\VMware\VMware Workstation\" >nul 2>nul
copy /y vpconfig.ini "%profilepath%\VMware\VMware Player\config.ini" >nul 2>nul
copy /y vmPerfmon.h "%WinDir%\inf\VMware\" >nul 2>nul
copy /y vmPerfmon.ini "%WinDir%\inf\VMware\0009\" >nul 2>nul
copy /y vnetinst.dll "%WinDir%\System32\" >nul 2>nul
echo.

echo 注册所需的DLL文件...
regsvr32 /s vmappcfg.dll
regsvr32 /s vmappsdk.dll
regsvr32 /s vmdbCOM.dll
echo.

echo 创建 __vmware_user__ 用户组 ...
net localgroup users __vmware_user__ /del >nul 2>nul
net localgroup __vmware__ /del >nul 2>nul
net user __vmware_user__ /del >nul 2>nul
echo.
net localgroup __vmware__ /add /comment:"VMware User Group"  >nul
if %errorlevel% neq 0 echo 用户组创建失败,请关闭杀毒软件或者HIPS后再重新安装VMware&pause>nul&exit

echo 安装VM基本服务 ...
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VMware\Performance" /v Library /t REG_SZ /d "%cd%\vmPerfmon.dll" /f
net stop vmx86 >nul 2>nul
sc delete vmx86 >nul 2>nul
start /wait vnetlib%vmbit%.exe -- install vmx86
start /wait vnetlib%vmbit%.exe -- start vmx86

net stop vmx86 >nul 2>nul
net start vmx86 >nul 2>nul
if %errorlevel% neq 0 echo 服务启动失败,请关闭杀毒软件或者HIPS后,再运行"卸载VMware.cmd"清理安装记录,然后重新安装VMware&pause>nul&exit

net stop vmci >nul 2>nul
sc delete vmci >nul 2>nul
if "%PROCESSOR_ARCHITECTURE%" neq "x86" (vmwarevmcisockets64.msi /quiet) else (vmwarevmcisockets.msi /quiet)

echo 创建快捷方式
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\VMware.lnk""):b.TargetPath=""%~dp0vmware.exe"":b.WorkingDirectory=""%~dp0\"":b.Save:close") >nul 2>nul

:ST
CALL Services.cmd
:EX
exit

:prompt
echo ..................
echo 提示:现在登录系统的并非是administrator用户
echo 安装VMware请切换到administrator管理员用户!
echo 如果系统未激活administrator用户，请在CMD
echo 命令行下使用"net user administrator /active:yes"
echo 这条命令激活administrator用户，这样注销系统后
echo 就能看到administrator账户了。登陆administrator
echo 用户就能安装VMware了。如果administrator用户名
echo 已经更名，在Vista/Win7/2008系统下，登陆改了名字
echo 的超级管理员账号，然后把此批处理的以"ver|find"开头
echo 的第9行和第10行删除掉再进行安装VMware。
echo ..................
pause
goto :EX