Windows Bat 编码/编程

BAT共通文件BatVarCom.bat内容:
set ROOT_PATH=C:\zhengys\qlik-view\qv-kawai\trunk\05_実装\src\Honban\
 
set COMPRESSION_EXE_PATH=C:\zhengys\software\7-Zip\7z.exe
 
set BACKUP_PATH=%ROOT_PATH%
 
set BATCH_PATH=%ROOT_PATH%Batch\
 
set VIEW_PATH=%ROOT_PATH%View\
 
set QVW_FILE_NAME=kawai.qvw
1. Bat执行系统服务:
@echo off
REM -------------------------------------------------------
REM - File: xxxxx.bat
REM - Description: Start all QlikView related services (v12)
REM -------------------------------------------------------
echo Start QlikView Services
echo ======================================================
 
net start "QlikView Server"
net start "QlikView WebServer"
net stop "QlikView WebServer"
net stop "QlikView Server"
 
echo ======================================================
echo All QlikView related services have been started ...
 
exit
2. 压缩整个文件夹为ZIP文件(使用7Z-zip压缩软件),错误时记录log日志:
@echo off
REM -------------------------------------------------------
REM - File: xxxxx.bat
REM - Description: copy Qvd and View folder to Backup by date name
REM -------------------------------------------------------
echo Start copy Qvd and View folder to Backup zip Services
echo ======================================================
 
REM - include comm file for vars
call comm\BatVarCom.bat
 
REM - create backup zip name by date
set DATE_NAME=%date:~0,4%%date:~5,2%%date:~8,2%
set QVD_ZIP_NAME=QVD_%DATE_NAME%.zip
set VIEW_ZIP_NAME=VIEW_%DATE_NAME%.zip
 
REM - if the logs folder is not exist, create it
IF NOT EXIST "logs\" MD "logs\"
 
REM - compress Qvd
IF NOT EXIST "%ROOT_PATH%Qvd\" goto QVD_ZIP_ERR
start %COMPRESSION_EXE_PATH% a -aoa %BACKUP_PATH%%QVD_ZIP_NAME% %ROOT_PATH%Qvd\
 
REM - compress View
IF NOT EXIST "%ROOT_PATH%View\" goto VIEW_ZIP_ERR
start %COMPRESSION_EXE_PATH% a -aoa %BACKUP_PATH%%VIEW_ZIP_NAME% %ROOT_PATH%View\
 
echo ======================================================
echo Copy Qvd and View folder to Backup zip services have been finished ...
 
exit
 
:QVD_ZIP_ERR
echo *** Copy Qvd folder to Backup zip Services, Qvd folder not exist %date% à %time% >>logs\KBODF090.log
 
:VIEW_ZIP_ERR
echo *** Copy View folder to Backup zip Services, View folder not exist %date% à %time% >>logs\KBODF090.log
3. copy文件到其他目录:
@echo off
REM -------------------------------------------------------
REM - File: xxxxx.bat
REM - Description: copy QVW from View dir QVW to Batch dir
REM -------------------------------------------------------
echo Start copy QVW from View dir QVW to Batch dir Services
echo ======================================================
 
REM - include comm file for vars
call comm\BatVarCom.bat
 
REM - if the logs folder is not exist, create it
IF NOT EXIST "logs\" MD "logs\"
 
REM - copy QVW from View dir QVW to Batch dir
IF NOT EXIST %VIEW_PATH%%QVW_FILE_NAME% goto QVW_COPY_ERR
IF EXIST %VIEW_PATH%%QVW_FILE_NAME% copy /Y %VIEW_PATH%%QVW_FILE_NAME% %BATCH_PATH%%QVW_FILE_NAME%
 
echo ======================================================
echo Copy copy QVW from View dir QVW to Batch dir services have been finished ...
 
exit
 
:QVW_COPY_ERR
echo *** Copy QVW from View dir QVW to Batch dir Services, Qvw file not exist %date% à %time% >>logs\KBODF097.log
4. move移动文件到其他目录:
@echo off
REM -------------------------------------------------------
REM - File: xxxxx.bat
REM - Description: move reloaded Batch dir QVW to View dir
REM -------------------------------------------------------
echo Start move reloaded Batch dir QVW to View dir Services
echo ======================================================
 
REM - include comm file for vars
call comm\BatVarCom.bat
 
REM - if the logs folder is not exist, create it
IF NOT EXIST "logs\" MD "logs\"
 
REM - move reloaded Batch dir QVW to View dir
IF NOT EXIST %BATCH_PATH%%QVW_FILE_NAME% goto QVW_MOVE_ERR
IF EXIST %BATCH_PATH%%QVW_FILE_NAME% move /Y %BATCH_PATH%%QVW_FILE_NAME% %VIEW_PATH%%QVW_FILE_NAME%
 
echo ======================================================
echo Move reloaded Batch dir QVW to View dir services have been finished ...
 
exit
 
:QVW_MOVE_ERR
echo *** Move QVW from View dir QVW to Batch dir Services, Qvw file not exist %date% à %time% >>logs\KBODF094.log

Related Posts

0 Comments

Leave a comment