@ECHO OFF
REM (ZZZZZZETC.BAT) 
IF "%5"=="" EXIT /B
SET I_EXIT=%SYSTEMDRIVE%\I\I.%4\TMP_%3\%5.EXIT
ECHO START ZZZZZZETC.BAT > %I_EXIT%
REM 1=IV (SHIFT)
SET I_VER=%1
SET I_FRAMEWORK=D
SHIFT
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=AT  6=out_file 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=COPY_DB_LOG_M 6=out_file 7=i_drive 8=in_path 9=in_file   
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=DIR 6=out_file 7="dir" 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=ERASE 6=erase_file 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=ERASE_LOG 6=erase_file 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=ERASE_TIME 6=hh.mm 7=pid 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=ERASE_MESSAGE 6=message_file 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=EXIST_MESSAGE 6=out_file 7=exist_file 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=NOP 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=PERMISSION 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=TYPE_ERROR_TIME 6=out_file 
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=WRITE_MESSAGE 6=message_file 7=color 8="message" 9=HALT  
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=SETUP_CLIENT 6=DB 7=server_name 8=system 9=lang
REM                                                  10=timeout_connect/timeout_sql 11=menu 12=title 13=framework 14=JDBC   
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=ERASE_CLIENT 6=DB 7=server_name 8=system 9=lang
REM                                                  10=timeout_connect/timeout_sql 11=menu 12=title 13=framework  
REM shift1/1=sys_lang 2={REAL,TEST} 3=system 4=work 5=BACKUP 6=DB   
SET I_TMP=%SYSTEMDRIVE%\I\I.%3\TMP_%2
IF "%5"=="NOP" GOTO FIN
IF "%5"=="PERMISSION" GOTO PERMISSION
IF "%6"=="" ECHO PARAMATER 2 SPACE > %I_EXIT% & EXIT /B
IF "%5"=="AT" GOTO AT
IF "%5"=="COPY_DB_LOG_M" GOTO COPY_DB_LOG_M
IF "%5"=="DIR" GOTO DIR
IF "%5"=="DIR_LOG" GOTO DIR_LOG
IF "%5"=="ERASE" GOTO ERASE
IF "%5"=="ERASE_LOG" GOTO ERASE_LOG
IF "%5"=="ERASE_TIME" GOTO ERASE_TIME
IF "%5"=="ERASE_MESSAGE" GOTO ERASE_MESSAGE
IF "%5"=="EXIST_MESSAGE" GOTO EXIST_MESSAGE
IF "%5"=="TYPE_ERROR_TIME" GOTO TYPE_ERROR_TIME
IF "%5"=="WRITE_MESSAGE" GOTO WRITE_MESSAGE
IF "%5"=="SETUP_CLIENT" GOTO SETUP_CLIENT
IF "%5"=="ERASE_CLIENT" GOTO ERASE_CLIENT
IF "%5"=="BACKUP" GOTO BACKUP
ECHO %5 ERROR > %I_EXIT%
EXIT /B
REM ===( AT 6=out_file )===
:AT
SCHTASKS /QUERY /NH > %I_TMP%\%6
GOTO FIN
REM ===( COPY_DB_LOG_M 6=out_file 7=i_drive: 8=in_path 9=in_file)===
:COPY_DB_LOG_M
COPY "%7\Program Files\Microsoft SQL Server\%8\%9" %I_TMP%\%6
GOTO FIN
REM ===( DIR 6=out_file,7=dir )===
:DIR
IF "%7"=="" GOTO FIN
DIR /L %7 > %I_TMP%\%6
GOTO FIN
REM ===( DIR_LOG 6=out_file,7=dir )===
:DIR_LOG
IF "%7"=="" GOTO FIN
DIR /L "%SYSTEMDRIVE%\I\I.%3\%2\LOG\%7" > %I_TMP%\%6
GOTO FIN
REM ===( ERASE 6=erase_file )===
:ERASE
IF EXIST %I_TMP%\%6 ERASE %I_TMP%\%6
GOTO FIN
REM ===( ERASE_LOG 6=erase_log )===
:ERASE_LOG
IF EXIST %SYSTEMDRIVE%\I\I.%3\%2\LOG\%6 ERASE %SYSTEMDRIVE%\I\I.%3\%2\LOG\%6
GOTO FIN
REM ===( ERASE_TIME 6=time,7=pid )===
:ERASE_TIME
IF NOT EXIST %SYSTEMDRIVE%\I\SHARE\MESSAGE\%1.%2.%3.%6*.TIME GOTO ERASE_TIME_J
ERASE        %SYSTEMDRIVE%\I\SHARE\MESSAGE\%1.%2.%3.%6*.TIME
:ERASE_TIME_J
IF "%7"=="" GOTO FIN
REM AT %7 /DELETE
SCHTASKS /DELETE /TN "%7" /F
GOTO FIN
REM ===( ERASE_MESSAGE 6=message_file )===
:ERASE_MESSAGE
IF NOT EXIST %SYSTEMDRIVE%\I\SHARE\MESSAGE\%2.%6 GOTO FIN
ERASE        %SYSTEMDRIVE%\I\SHARE\MESSAGE\%2.%6  
GOTO FIN
REM ===( EXIST_MESSAGE 6=out_file,7=message_file )===
:EXIST_MESSAGE
IF "%7"=="" GOTO FIN
IF EXIST %SYSTEMDRIVE%\I\SHARE\MESSAGE\%2.%7 GOTO EXIST_MESSAGE_J
ECHO NOT FOUND > %I_TMP%\%6
GOTO FIN
:EXIST_MESSAGE_J
ECHO !!! FOUND > %I_TMP%\%6
GOTO FIN
REM ===( PERMISSION )===
:PERMISSION
COPY  %I_TMP%\Z_PERMISSION.CFG %SYSTEMDRIVE%\I\I.%3\BAT\ 2> %I_EXIT%
IF ERRORLEVEL 1 EXIT /B 
ERASE %I_TMP%\Z_PERMISSION.CFG
GOTO FIN
REM ===( TYPE_ERROR_TIME 6=out_file )===
:TYPE_ERROR_TIME
IF NOT EXIST %SYSTEMDRIVE%\I\SHARE\MESSAGE\*ERR.TIME GOTO TYPE_ERROR_TIME_J
TYPE %SYSTEMDRIVE%\I\SHARE\MESSAGE\*ERR.TIME | SORT /+20 > %I_TMP%\%6
GOTO FIN
:TYPE_ERROR_TIME_J
ECHO ERROR TIME NOT FOUND > %I_TMP%\%6
GOTO FIN
REM ===( WRITE_MESSAGE 6=message_file 7=color 8=message 9=HALT )===
IF "%8"=="" GOTO FIN 
ECHO %7 %8 %3 > %SYSTEMDRIVE%\I\SHARE\MESSAGE\%2.%6
IF NOT "%9"=="HALT" GOTO FIN 
START %SYSTEMDRIVE%\I\BIN%I_VER%\%I_VER%MENUW%I_FRAMEWORK%.EXE %1 %SYSTEMDRIVE%\I\BIN%I_VER%\%I_VER%_HALT.TXT ZZZZZZ_ARG_FILE=%SYSTEMDRIVE%\I\SHARE\MESSAGE\%2.%6
GOTO FIN
REM ===(5=SETUP_CLIENT)=====
REM 1=sys_lang 2={REAL,TEST} 3=system 4=work 5=SETUP_CLIENT 6=DB 7=server_name 8=system 9=lang 10=timeout_connect/"timeout_sql 11=menu 12=title 13=framework 14=JDBC  
:SETUP_CLIENT
IF NOT "%2"=="REAL" GOTO FIN
shift&shift&shift&shift&shift
REM 1=DB 2=server_name 3=system 4=lang 5=timeout_connect/timeout_sql 6=menu 7=title 8=framework 9=JDBC  
SET I_SHARE=%SystemDrive%\I\SHARE
SET I_FL1=SETUP_%3_%4_%6
SET I_FL2W=
SET I_FL2U=_MONO
SET I_DJC=D
:CLIENT_LOOP
SET I_FLW=%I_SHARE%\WINDOWS\%I_FL1%%I_FL2W%.BAT
SET I_FLU=%I_FL1%%I_FL2U%
ECHO @ECHO OFF > %I_FLW%
ECHO IF NOT EXIST \I     MKDIR \I     >> %I_FLW% 
ECHO IF NOT EXIST \I\TMP MKDIR \I\TMP >> %I_FLW% 
ECHO COPY \\%2\I_SHARE\WINDOWS\CLIENT\%I_VER%CLIENT.BAT \I\TMP >> %I_FLW% 
ECHO CALL \I\TMP\%I_VER%CLIENT.BAT \\%2\I_SHARE\WINDOWS %I_VER% %1 %4 %5 I_%2_%3.I %6 %7 %I_DJC% %9 >> %I_FLW% 
REM ECHO PAUSE >> %I_FLW%
REM ECHO /bin/sh ./CLIENT/%I_VER%CLIENT.SH %I_VER% CLIENT %1 %4 %5 I_%2_%3.I %6 %7 %9>  %I_LINUX%\CLIENT\SETUP_%3_%4_%6_JAVA.SJIS
REM %SystemDrive%\I\BIN%I_VER%\%I_VER%MENUW%I_FRAMEWORK%.EXE %I_L INUX%\CLIENT\CONVERT.TXT ZZZZZZ_ABORT=NO IN=%I_LINUX%\CLIENT\SETUP_%3_%4_%6_JAVA.SJIS IN_ENCODE=SHIFT_JIS OUT=%I_LINUX%\SETUP_%3_%4_%6_JAVA OUT_ENCODE=,U 
REM ECHO /bin/sh ./CLIENT/%I_VER%CLIENT.SH %I_VER% CLIENT %1 %4 %5 I_%2_%3.I %6 %7>  %I_LINUX%\CLIENT\SETUP_%3_%4_%6_MONO.SJIS
REM %SystemDrive%\I\BIN%I_VER%\%I_VER%MENUW%I_FRAMEWORK%.EXE %I_LINUX%\CLIENT\CONVERT.TXT ZZZZZZ_ABORT=NO IN=%I_LINUX%\CLIENT\SETUP_%3_%4_%6_MONO.SJIS IN_ENCODE=SHIFT_JIS OUT=%I_LINUX%\SETUP_%3_%4_%6_MONO OUT_ENCODE=,U 
REM ECHO /bin/sh ./CLIENT/%I_VER%CLIENT.SH %I_VER% CLIENT %1 %4 %5 I_%2_%3.I %6 %7 %I_DJC% %9>  %I_SHARE%\LINUX\CLIENT\%I_FLU%.SJIS
ECHO /bin/sh ./CLIENT/%I_VER%CLIENT.SH %I_VER% %1 %4 %5 I_%2_%3.I %6 %7 %I_DJC% %9>  %I_SHARE%\LINUX\CLIENT\%I_FLU%.SJIS
%SystemDrive%\I\BIN%I_VER%\IMENUW%I_FRAMEWORK%.EXE %I_SHARE%\LINUX\CLIENT\CONVERT.TXT ZZZZZZ_ABORT=NO IN=%I_SHARE%\LINUX\CLIENT\%I_FLU%.SJIS IN_ENCODE=SHIFT_JIS OUT=%I_SHARE%\LINUX\%I_FLU% OUT_ENCODE=,U 
IF "%I_DJC%"=="C" GOTO CLIENT_END
IF "%I_DJC%"=="D" GOTO CLIENT_JAVA
SET I_DJC=C
SET I_FL2W=_CPP
SET I_FL2U=_CPP
GOTO CLIENT_LOOP
:CLIENT_JAVA
SET I_DJC=J
SET I_FL2W=_JAVA
SET I_FL2U=_JAVA
GOTO CLIENT_LOOP
:CLIENT_END
GOTO FIN
REM ===(5=ERASE_CLIENT)=====
:ERASE_CLIENT
IF NOT "%2"=="REAL" GOTO FIN
shift&shift&shift&shift&shift
REM 1=DB 2=server_name 3=system 4=lang 5=timeout_connect/timeout_sql 6=menu 7=title  
SET I_FL=%SystemDrive%\I\SHARE\WINDOWS\SETUP_%3_%4_%6.BAT
ERASE %I_FL%
SET I_FL=%SystemDrive%\I\SHARE\LINUX\SETUP_%3_%4_%6_MONO
ERASE %I_FL%
SET I_FL=%SystemDrive%\I\SHARE\LINUX\SETUP_%3_%4_%6_JAVA
ERASE %I_FL%
GOTO FIN
:BACKUP
ECHO ZZZZETC ERROR>%I_EXIT% 
IF "%6"=="I" GOTO I
IF "%6"=="P" GOTO P
IF ERRORLEVEL 1 EXIT /B 
GOTO FIN 
:I
DB2CMD -W -C "DB2 BACKUP DATABASE I_%3 ONLINE TO %SYSTEMDRIVE%\I\I.%3 1>%I_EXIT%" 
GOTO FIN
:P
SET F=%SYSTEMDRIVE%\PROGRAM FILES\POSTGRESQL\8.4\BIN\PG_DUMP.EXE
IF EXIST "%F%" GOTO P2 
SET F=%SYSTEMDRIVE%\PROGRAM FILES\POSTGRESQL\8.3\BIN\PG_DUMP.EXE
IF EXIST "%F%" GOTO P2 
GOTO FIN 
:P2
"%F%" -U postgres i_%3 1>%SYSTEMDRIVE%\I\%3.I\PG_DUMP-I_%3.TXT 2>%I_EXIT% 
IF ERRORLEVEL 1 EXIT /B 
ECHO !!!>%I_EXIT% 
:FIN
ECHO !!! > %I_EXIT%
