web release (bat tool)
准备当前目录下的:
空SWSK 文件夹
空ZIP文件夹
0. RealseExclude.txt
\obj\
.err
.log
.pdb
1. 发布BAT文件
chcp 932
@echo off
echo ##############################################################
echo SRC must be copyed into "SWSK" .Has it already been copyed?
echo Y.Yes
echo N.No
echo ##############################################################
echo.
rmdir /s/q SWSK
xcopy "../SVN-swsk_web\trunk\SWSK" "SWSK" /EXCLUDE:RealseExclude.txt /e /h /i /y
rmdir "SWSK/SWSK_Frame/SWSK_Frame/WebSite/Log" /s /q
echo %date% %time% --------------------------[DESTSERVER] Realse Begin----------------------------------------->>log.txt
net use \\[DESTSERVER]\C$\inetpub\wwwroot /USER:[USER] [PASSWORD]
if %ERRORLEVEL% EQU 0 (echo %date% %time% Access to the server:[DESTSERVER]>>log.txt ) else (echo %date% %time% Failed to Access the server:[DESTSERVER]>>log.txt)
sc \\[DESTSERVER] stop W3SVC
if %ERRORLEVEL% EQU 0 (echo %date% %time% The IIS services has been shutted down at [DESTSERVER]>>log.txt ) else (echo %date% %time% Failed to shutted down the IIS services at [DESTSERVER].>>log.txt)
copy "\\[DESTSERVER]\C$\inetpub\wwwroot\SWSK_NEW2\SWSK_Frame\SWSK_Frame\WebSite\Conf\DB.xml" "SWSK/SWSK_Frame/SWSK_Frame/WebSite/Conf/" /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% DB.xml was copied.>>log.txt ) else (echo %date% %time% Failed to copy DB.xml.>>log.txt)
copy "\\[DESTSERVER]\C$\inetpub\wwwroot\SWSK_NEW2\SWSK_Frame\SWSK_Frame\WebSite\Conf\Setting.xml" "SWSK/SWSK_Frame/SWSK_Frame/WebSite/Conf/" /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% Setting.xml was copied.>>log.txt ) else (echo %date% %time% Failed to copy Setting.xml.>>log.txt)
copy "\\[DESTSERVER]\C$\inetpub\wwwroot\SWSK_NEW2\SWSK_Frame\SWSK_Frame\WebSite\img\head_title.jpg" "SWSK/SWSK_Frame/SWSK_Frame/WebSite/img/" /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% head_title.jpg was copied.>>log.txt ) else (echo %date% %time% Failed to copy head_title.jpg.>>log.txt)
copy "\\[DESTSERVER]\C$\inetpub\wwwroot\SWSK_NEW2\SWSK_Frame\SWSK_Frame\WebSite\WebFront\A15Aplication\GA01102.aspx" "SWSK/SWSK_Frame/SWSK_Frame/WebSite/WebFront/A15Aplication/" /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% GA01102.aspx was copied.>>log.txt ) else (echo %date% %time% Failed to copy GA01102.aspx.>>log.txt)
xcopy "\\[DESTSERVER]\C$\inetpub\wwwroot\SWSK_NEW2\SWSK_Frame\SWSK_Frame\WebSite\Log" "SWSK/SWSK_Frame/SWSK_Frame/WebSite/Log" /e /h /i /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% Log was copied.>>log.txt ) else (echo %date% %time% Failed to copy Log.>>log.txt)
pushd "\\[DESTSERVER]\C$\inetpub\wwwroot"
FOR /d %%i IN (SWSK_OLD/SWSK_NEW2_20*) DO rmdir "SWSK_OLD/%%i" /s /q
if %ERRORLEVEL% EQU 0 (echo %date% %time% The backup of SWSK_NEW2 was deleted.>>log.txt ) else (echo %date% %time% Failed to deleted the backup of SWSK_NEW2.>>log.txt)
FOR /d %%i IN (SWSK_NEW2_20*) DO move %%i SWSK_OLD
if %ERRORLEVEL% EQU 0 (echo %date% %time% The file was backuped up.>>log.txt ) else (echo %date% %time% Failed to backup up the file.>>log.txt)
set curtime=%time:~0,2%%time:~3,2%
setlocal enabledelayedexpansion
set curtime=!curtime: =0!
setlocal disabledelayedexpansion
ren "SWSK_NEW2" SWSK_NEW2_%date:~0,4%%date:~5,2%%date:~8,2%%curtime%
if %ERRORLEVEL% EQU 0 (echo %date% %time% The file was renamed.>>log.txt ) else (echo %date% %time% Failed to renamed the file.>>log.txt)
popd
xcopy "SWSK" "\\[DESTSERVER]\C$\inetpub\wwwroot\SWSK_NEW2" /EXCLUDE:RealseExclude.txt /e /h /i /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% Web file was copied to [DESTSERVER] as SWSK_NEW2 successfully!.>>log.txt ) else (echo %date% %time% Failed to copy Web file to [DESTSERVER] as SWSK_NEW2.>>log.txt)
icacls "\\[DESTSERVER]\C$\inetpub\wwwroot\SWSK_NEW2\SWSK_Frame\SWSK_Frame\WebSite\log" /grant BUILTIN\IIS_IUSRS:(OI)(CI)(M,W) /t /q
sc \\[DESTSERVER] start W3SVC
if %ERRORLEVEL% EQU 0 (echo %date% %time% The IIS services was restarted at [DESTSERVER].>>log.txt ) else (echo %date% %time% Failed to restarted the IIS services at [DESTSERVER].>>log.txt)
net use \\[DESTSERVER]\C$\inetpub\wwwroot /del /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% Disconnect to the server:[DESTSERVER].>>log.txt ) else (echo %date% %time% Failed to disconnect to the server:[DESTSERVER].>>log.txt)
rmdir "SWSK/SWSK_Frame/SWSK_Frame/WebSite/Log" /s /q
md "SWSK/SWSK_Frame/SWSK_Frame/WebSite/Log"
zip SWSK_%date:~0,4%%date:~5,2%%date:~8,2%%curtime% "SWSK" -r
move SWSK_%date:~0,4%%date:~5,2%%date:~8,2%%curtime%.zip "zip"
echo.
echo SWSK be Released in Server:[DESTSERVER] successfully!
echo.
pause
echo %date% %time% --------------------------[DESTSERVER] Realse End----------------------------------------->>log.txt
ren "log.txt" log_%date:~0,4%%date:~5,2%%date:~8,2%%curtime%.txt