@ECHO OFF
REM SET_END.BAT HARASWA %1=VERSION1 %2=SYSTEM %3=OS %4=lang %5=param %6=param_file %7=password_admin,  ##/ %8,%9=PATH 
IF "%3"=="" EXIT /B
REM SET I_DD=%8
REM IF NOT "%9"=="" SET I_DD=%8 %9
SET I_FRAMEWORK=D
SET I_VER=%1
SET I_HOME=%SYSTEMDRIVE%\I
SET I_SYSTEM_DIR=%I_HOME%\I.%2
SET I_FILE=%I_HOME%\TMP\SETUP_%2_END.TXT
NET START SCHEDULE 2>%I_FILE%
FOR    %%I IN (%I_HOME% %I_SYSTEM_DIR% %I_SYSTEM_DIR%\BAT) DO MKDIR %%I                       2>>%I_FILE%
FOR    %%I IN (DATA TMP) DO  FOR %%J IN (REAL TEST) DO MKDIR %I_SYSTEM_DIR%\%%I_%%J           2>>%I_FILE%
FOR /L %%I IN (1,1,9)                               DO MKDIR %I_SYSTEM_DIR%\DATA_OLD%%I_REAL  2>>%I_FILE%
REM XCOPY /C /E /I /Y                         "%I_DD%\I_SERVER\SHARE"      %I_HOME%\SHARE     2>>%I_FILE%
REM XCOPY /C /E /I /Y                         "%I_DD%\I_SERVER\%3\SERVICE" %I_HOME%\SERVICE   2>>%I_FILE%
REM XCOPY /C    /I /Y                         "%I_DD%\I_SERVER\%3\I*"      %I_HOME%\          2>>%I_FILE%
REM FOR %%I IN (BAT BIN) DO XCOPY /C /E /I /Y "%I_DD%\I_SERVER\%3\%%I"     %I_SYSTEM_DIR%\%%I 2>>%I_FILE%
SET I_XCOPYF=XCOPY /C /D /H /I /K /R /V /Y
REM ===HOME===
IF NOT EXIST %I_HOME% MKDIR %I_HOME%
FOR %%I IN (RESCUE.BAT RESCUE.TXT UNINSTALL.BAT UNINSTALL.TXT SRVCWD_ADD.BAT SRVCWD_REMOVE.BAT) DO COPY /Y IXX%%I %I_HOME%\%I_VER%%%I 
REM ===SERVER==== 
%I_XCOPYF% ZZZZZZ*.BAT     %I_SYSTEM_DIR%\BAT 
REM ====SHARE====
IF NOT EXIST %I_HOME%\SHARE\MESSAGE      MKDIR %I_HOME%\SHARE\MESSAGE
IF NOT EXIST %I_HOME%\SHARE\LINUX\CLIENT MKDIR %I_HOME%\SHARE\LINUX\CLIENT
COPY /Y IXXCLIENT.SH                    %I_HOME%\SHARE\LINUX\CLIENT\%I_VER%CLIENT.SH 
%I_XCOPYF% CONVERT.TX?                  %I_HOME%\SHARE\LINUX\CLIENT 
%I_XCOPYF% %I_HOME%\TMP\%6*             %I_HOME%\SHARE\LINUX\CLIENT
%I_XCOPYF% I.IC?                        %I_HOME%\SHARE\LINUX\BIN%I_VER% 
%I_XCOPYF% I_MENU.*                     %I_HOME%\SHARE\LINUX\BIN%I_VER% 
%I_XCOPYF% I_LANG??U.TXT                %I_HOME%\SHARE\LINUX\BIN%I_VER% 
%I_XCOPYF% ..\%I_VER%_BIN\CLIENT_UD\*.* %I_HOME%\SHARE\LINUX\BIN%I_VER%D 
%I_XCOPYF% ..\%I_VER%_BIN\JAVA\*.*      %I_HOME%\SHARE\LINUX\BIN%I_VER%J 
%I_XCOPYF% ..\i-download\*.jar          %I_HOME%\SHARE\LINUX\BIN%I_VER%J 
%I_XCOPYF% ..\%I_VER%_BIN\CLIENT_UC\*.* %I_HOME%\SHARE\LINUX\BIN%I_VER%C 

IF NOT EXIST %I_HOME%\SHARE\WINDOWS\CLIENT MKDIR %I_HOME%\SHARE\WINDOWS\CLIENT
COPY /Y IXXCLIENT.BAT                   %I_HOME%\SHARE\WINDOWS\CLIENT\%I_VER%CLIENT.BAT 
COPY /Y IXXCLIENT.JS                    %I_HOME%\SHARE\WINDOWS\CLIENT\%I_VER%CLIENT.JS 
%I_XCOPYF% CONVERT.TX?                  %I_HOME%\SHARE\WINDOWS\CLIENT
%I_XCOPYF% %I_HOME%\TMP\%6*             %I_HOME%\SHARE\WINDOWS\CLIENT
REM %I_XCOPYF% I.IC?                        %I_HOME%\SHARE\WINDOWS\BIN%I_VER% 
%I_XCOPYF% I_MENU.*                     %I_HOME%\SHARE\WINDOWS\BIN%I_VER% 
%I_XCOPYF% I_LANG??W.TXT                %I_HOME%\SHARE\WINDOWS\BIN%I_VER% 
%I_XCOPYF% ..\%I_VER%_BIN\CLIENT_WD\*.* %I_HOME%\SHARE\WINDOWS\BIN%I_VER%D 
%I_XCOPYF% ..\%I_VER%_BIN\JAVA\*.*      %I_HOME%\SHARE\WINDOWS\BIN%I_VER%J 
%I_XCOPYF% ..\i-download\*.jar          %I_HOME%\SHARE\WINDOWS\BIN%I_VER%J 
%I_XCOPYF% ..\%I_VER%_BIN\CLIENT_WC\*.* %I_HOME%\SHARE\WINDOWS\BIN%I_VER%C 

ICACLS %I_HOME%\SHARE           /grant:r EVERYONE:(OI)(CI)(R)
ICACLS %I_HOME%\SHARE\MESSAGE   /grant:r EVERYONE:(OI)(CI)(R)
ICACLS %I_SYSTEM_DIR%\DATA_TEST /grant:r EVERYONE:(OI)(CI)(F)
REM (VER31.1) CALL %I_HOME%\SERVICE\I%1ADD.BAT ROOT 2>>%I_FILE%
FOR %%I IN (LINUX WINDOWS) DO COPY %I_SYSTEM_DIR%\BAT\*.I %I_HOME%\SHARE\%%I\CLIENT 2>>%I_FILE%
NET SHARE I_SHARE=%I_HOME%\SHARE    /GRANT:EVERYONE,READ /REMARK:"I_CLIENT_SETUP(16>=VER)" 2>>%I_FILE%
NET SHARE I.%2=%I_SYSTEM_DIR%\DATA_TEST /GRANT:EVERYONE,FULL /REMARK:"I_%2_DATA_TEST" 2>>%I_FILE%
FOR /L %%I IN (1,1,2) DO WSCRIPT.EXE SET_END.JS %1 %4 %5 %6 ZZZZ01050%%I %1SERVER_%2_0%%I %I_FRAMEWORK% 
REM ===( %I_VER%SRVCWD_ADD.BAT )==== 
PUSHD %I_HOME%
CALL %I_VER%SRVCWD_ADD.BAT ROOT
POPD
REM ===================
IF "%7"=="/" EXIT /B
REM ===( ZZZZZZPASSWORD.BAT )==== 
EHCO SET PASSWORD=%7 > %I_SYSTEM_DIR%\ZZZZZZPASSWORD.BAT
REM EHCO Y>%I_HOME%\TMP\Y.TXT
ICACLS %I_SYSTEM_DIR%\ZZZZZZPASSWORD.BAT /remove everyone /grant:r SYSTEM:F /grant:r ADMINISTRATORS:F /grant:r %USERNAME%:F 
