远程Release用Bactch处理

chcp 932
@echo off
echo ##############################################################
echo SRC must be copyed into "PROJECTA" .Has it already been copyed?
echo Y.Yes
echo N.No
echo ##############################################################
echo.
rmdir /s/q PROJECTA
xcopy "../PROJECTA" "PROJECTA" /EXCLUDE:ReleaseExclude.txt /e /h /i /y
rmdir "PROJECTA/PROJECTA_Frame/PROJECTA_Frame/WebSite/Log" /s /q
echo %date% %time% --------------------------192.168.1.101 Release Begin----------------------------------------->>log.txt
net use \\192.168.1.101\C$\inetpub\wwwroot /USER:sadmin S3300625!
if %ERRORLEVEL% EQU 0 (echo %date% %time% Access to the server:192.168.1.101>>log.txt ) else (echo %date% %time% Failed to Access the server:192.168.1.101>>log.txt)
sc \\192.168.1.101 stop W3SVC
if %ERRORLEVEL% EQU 0 (echo %date% %time% The IIS services has been shutted down at 192.168.1.101>>log.txt ) else (echo %date% %time% Failed to shutted down the IIS services at 192.168.1.101.>>log.txt)
copy "\\192.168.1.101\C$\inetpub\wwwroot\PROJECTA_TEST\PROJECTA_Frame\PROJECTA_Frame\WebSite\Conf\DB.xml" "PROJECTA/PROJECTA_Frame/PROJECTA_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 "\\192.168.1.101\C$\inetpub\wwwroot\PROJECTA_TEST\PROJECTA_Frame\PROJECTA_Frame\WebSite\Conf\Setting.xml" "PROJECTA/PROJECTA_Frame/PROJECTA_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 "\\192.168.1.101\C$\inetpub\wwwroot\PROJECTA_TEST\PROJECTA_Frame\PROJECTA_Frame\WebSite\img\head_title.jpg" "PROJECTA/PROJECTA_Frame/PROJECTA_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 "\\192.168.1.101\C$\inetpub\wwwroot\PROJECTA_TEST\PROJECTA_Frame\PROJECTA_Frame\WebSite\WebFront\A15Aplication\GA01102.aspx" "PROJECTA/PROJECTA_Frame/PROJECTA_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 "\\192.168.1.101\C$\inetpub\wwwroot\PROJECTA_TEST\PROJECTA_Frame\PROJECTA_Frame\WebSite\Log" "PROJECTA/PROJECTA_Frame/PROJECTA_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 "\\192.168.1.101\C$\inetpub\wwwroot"
FOR /d %%i IN (PROJECTA_OLD/PROJECTA_TEST_20*) DO rmdir "PROJECTA_OLD/%%i" /s /q
if %ERRORLEVEL% EQU 0 (echo %date% %time% The backup of PROJECTA_TEST was deleted.>>log.txt ) else (echo %date% %time% Failed to deleted the backup of PROJECTA_TEST.>>log.txt)
FOR /d %%i IN (PROJECTA_TEST_20*) DO move %%i PROJECTA_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 "PROJECTA_TEST" PROJECTA_TEST_%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 "PROJECTA" "\\192.168.1.101\C$\inetpub\wwwroot\PROJECTA_TEST" /EXCLUDE:ReleaseExclude.txt /e /h /i /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% Web file was copied to 192.168.1.101 as PROJECTA_TEST successfully!.>>log.txt ) else (echo %date% %time% Failed to copy Web file to 192.168.1.101 as PROJECTA_TEST.>>log.txt)
icacls "\\192.168.1.101\C$\inetpub\wwwroot\PROJECTA_TEST\PROJECTA_Frame\PROJECTA_Frame\WebSite\log" /grant BUILTIN\IIS_IUSRS:(OI)(CI)(M,W) /t /q
sc \\192.168.1.101 start W3SVC
if %ERRORLEVEL% EQU 0 (echo %date% %time% The IIS services was restarted at 192.168.1.101.>>log.txt ) else (echo %date% %time% Failed to restarted the IIS services at 192.168.1.101.>>log.txt)
net use \\192.168.1.101\C$\inetpub\wwwroot /del /y
if %ERRORLEVEL% EQU 0 (echo %date% %time% Disconnect to the server:192.168.1.101.>>log.txt ) else (echo %date% %time% Failed to disconnect to the server:192.168.1.101.>>log.txt)
rmdir "PROJECTA/PROJECTA_Frame/PROJECTA_Frame/WebSite/Log" /s /q
md "PROJECTA/PROJECTA_Frame/PROJECTA_Frame/WebSite/Log"
zip PROJECTA_%date:~0,4%%date:~5,2%%date:~8,2%%curtime% "PROJECTA" -r
move PROJECTA_%date:~0,4%%date:~5,2%%date:~8,2%%curtime%.zip "zip"
echo.
echo PROJECTA be Released in Server:192.168.1.101 successfully!
echo.
pause
echo %date% %time% --------------------------192.168.1.101 Realse End----------------------------------------->>log.txt
ren "log.txt" log_%date:~0,4%%date:~5,2%%date:~8,2%%curtime%.txt
posted @ 2017-10-17 15:51  tomclock  阅读(265)  评论(0编辑  收藏  举报