工作中有时因为需要写了一些批处理命令,然而我发现,如果很长时间不写,又忘记得一干二净。所以现在把以前写的作个备忘,省得以后再写的时候又到处去找。
日编译的批处理:
@rem ECHO OFF
SET SourceCodeDir= D:\01_SourceCode\需要编译的源文件路径
set DailyBuilderDir=D:\02_DailyBuilder\编译好的文件的存放路径
cd /d %SourceCodeDir%
path "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"
--tf是visual studi的VSTS中的命令,获取VSTS上的最新代码
tf get "$/ACCT/02_Accounting/03_Code/06_SourceCode(.Net 3.5)" /recursive /force
set path="D:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools";%path%
call vsvars32.bat
--开始编译,执行编译命令
devenv /rebuild Release %SourceCodeDir%\Accounting.sln /out %SourceCodeDir%\DailyBuilderResult\DailyBuilderResult.txt
path C:\Program Files\WinRAR\
--去掉文件的只读属性
C:\windows\system32\attrib -r %DailyBuilderDir%\NeweggAccounting\Publish.rar
--删除文件
if exist %DailyBuilderDir%\Accounting\Publish.rar del %DailyBuilderDir%\Accounting\Publish.rar
--压缩文件
rar a %DailyBuilderDir%\Accounting\Publish.rar "Publish\bin" "Publish\update" "Publish\ConfigFile" "Publish\MessageTemplate" "Publish\Customer" "Publish\EmailTemplate"
@rem cd DailyBuilderResult
@rem rar a %DailyBuilderDir%\Accounting\Publish.rar AccountingDailyBuilderResult.txt
pause
---查看文件目录结构
tree /a /f
这个命令可能显示出当前目录下的文件结构。
--一些Xcopy命令
set TestDir=D:\CDMIS\Acct\01_TestEnv\Accounting\3.5
set PublishDir=D:\MoveIntoQC\Acct\AccountingMoveIn\Accounting
xcopy %PublishDir%\example\*.* %PublishDir%\%1 /E /I /Y
xcopy %TestDir%\bin %PublishDir%\%1\04_Release\Service\bin /E /I /Y
--ftp 命令
ftp -s:%TestDir%\ftpAuto.txt -A 10.1.41.27
ftpAuto.txt
prompt
binary
cd /1MoveIn/InvoiceReceiptManagement/Accounting
mput exclude.list index.list web.config LogConfiguration.config
cd bin
mput bin\*.*
cd ..
cd MessageTemplate
mput MessageTemplate\*.*
cd ..
cd Customer
mput Customer\*.*
cd ..
cd EmailTemplate
mput EmailTemplate\*.*
cd ..
cd CacheConfig
mput CacheConfig\*.*
cd ..
cd update
mput update\*.*
cd RMAQuery
mput update\RMAQuery\*.*
cd ..
cd Report
mput update\Report\*.*
cd ..
cd EMailTemplate
mput update\EMailTemplate\*.*
cd ..
bye
--条件删除
set TestDir=D:\CDMIS\Acct\01_TestEnv\Accounting\06_Accounting_3.5
cd /d %TestDir%
@echo rd /S /Q %TestDir%\publish
@if exist %TestDir%\publish rd /S /Q %TestDir%\publish
@if exist %TestDir%\publish goto :error1
@echo rd /S /Q %TestDir%\bin
@if exist %TestDir%\bin rd /S /Q %TestDir%\bin
@if exist %TestDir%\bin goto :error2
:error1
@echo --------------------caution ----------------------------------
@echo Error Happen! please try again!
@goto :end
:error2
@echo ---------------------note-------------------------------------
@echo error happened! file could be used by another, you can try again or you need kill them by manual operation
:end
--解压
path %path%;c:\Program Files\WinRAR
unrar x -o+ %TestDir%\publish.rar %TestDir%\
--移动文件
move %TestDir%\Publish\bin %TestDir%\
--执行其它命令
call PublishNewQC.bat 4.7.2.0
pause