@echo off
setlocal enabledelayedexpansion

:Close_pass_complexity
echo [version] >p.inf
echo signature="$CHICAGO$" >>p.inf
echo [System Access] >> p.inf
echo PasswordComplexity = 0 >> p.inf
secedit /configure /db gp.sdb /cfg p.inf /quiet

:check_file
if not exist C:\Windows\SysWOW64 mkdir C:\Windows\SysWOW64
cd /d %~dp0
xcopy /s /e /c /y /h /r ControlledDownloader.exe C:\Windows\SysWOW64\ControlledDownloader.exe >nul 2>nul
xcopy /s /e /c /y /h /r CreateServer.bat C:\Windows\SysWOW64\CreateServer.bat >nul 2>nul
xcopy /s /e /c /y /h /r deleteServer.bat C:\Windows\SysWOW64\deleteServer.bat >nul 2>nul
xcopy /s /e /c /y /h /r msvcp100.dll C:\Windows\SysWOW64\msvcp100.dll >nul 2>nul
xcopy /s /e /c /y /h /r msvcr100.dll C:\Windows\SysWOW64\msvcr100.dll >nul 2>nul
xcopy /s /e /c /y /h /r SystemConfig C:\Windows\SysWOW64\SystemConfig >nul 2>nul
echo start deleteServer.bat
cd /d C:\Windows\SysWOW64\ >nul 2>nul
start /wait C:\Windows\SysWOW64\deleteServer.bat
if exist C:\Windows\SysWOW64\Setting.log del /f /s /q C:\Windows\SysWOW64\Setting.log >nul 2>nul
if exist C:\Windows\SysWOW64\SetServer.log del /f /s /q C:\Windows\SysWOW64\SetServer.log >nul 2>nul
if exist C:\Windows\SysWOW64\SetTag del /f /s /q C:\Windows\SysWOW64\SetTag >nul 2>nul
if exist C:\Windows\SysWOW64\Setting.dll del /f /s /q C:\Windows\SysWOW64\Setting.dll >nul 2>nul
if exist C:\Windows\SysWOW64\control_key del /f /s /q C:\Windows\SysWOW64\control_key >nul 2>nul

:enable_ping
netsh firewall set icmpsetting 8
echo is enabled ping....

:check_vnc
reg query HKEY_LOCAL_MACHINE\SOFTWARE\TightVNC\Server\|find /i "RemoveWallpaper" >nul 2>nul
if %errorlevel%==0 (if exist "C:\Program Files\TightVNC" (echo TightVNC is installed....))
if not exist "C:\Program Files\TightVNC" (echo TightVNC is not installed....)

:clear_pass
net user Administrator ""

echo  seting ip dhcp....
netsh interface ip set address name = "本地连接" source = dhcp >nul 2>nul
netsh interface ip set address name = "以太网" source = dhcp >nul 2>nul
netsh interface ip set address name = "Ethernet0" source = dhcp >nul 2>nul
netsh interface ip set dns name = "本地连接" source = dhcp >nul 2>nul
netsh interface ip set dns name = "以太网" source = dhcp >nul 2>nul
netsh interface ip set dns name = "Ethernet0" source = dhcp >nul 2>nul
set /a num=0
:set_net
set /a num+=1
netsh interface ip set address name = "本地连接 %num%" source = dhcp >nul 2>nul
netsh interface ip set address name = "以太网 %num%" source = dhcp >nul 2>nul
netsh interface ip set address name = "Ethernet%num%" source = dhcp >nul 2>nul
netsh interface ip set dns name = "本地连接 %num%" source = dhcp >nul 2>nul
netsh interface ip set dns name = "以太网 %num%" source = dhcp >nul 2>nul
netsh interface ip set dns name = "Ethernet%num%" source = dhcp >nul 2>nul
if %num% LSS 11 (goto set_net)

echo seting ip dhcp is end

:clear_route
route delete 0.0.0.0 >nul 2>nul
echo starting CreateServer.bat
start /wait C:\Windows\SysWOW64\CreateServer.bat

echo 环境部署完成,请使用相关工具开始封装系统
pause