May 11, 2005

Batch Files

Batch file help
Batch file Command Line Parameters
Run Batch File in C#
Batch File To Clean A Build
To put all output from a command in a file (erases existing file):
command > filename  
To APPEND output to a file (great for log files):
command >> filename  
To use output from one command as input for another:
command1 | command2 
Want a certain batch file to clear the screen after running?:
echo @cls >> batfile.bat
Want to view a text file, a page at a time?:
type filename.txt  more
Use call to invoke another batch file:
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
Echo to just display a line of text in the output:
ECHO ========== Started ==========
PAUSE to make the batchfile pause until a key is pressed:
ECHO ========== Finished ==========
PAUSE
Here is an example build script:
ECHO ========== Started ==========
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
F:
cd F:\SourceControl\XXX
ECHO ========== CLEAN ==========
del /F /S /Q win32_vs90
del /F /S /Q win32_vs100
del /F /S /Q obj\d32
del /F /S /Q obj\r32
del /F /S /Q *.suo
del /F /S /Q *.ncb
del /F /S /Q *.user
msbuild /t:clean
ECHO ========== Syncing to change list 285519 ==========
p4 sync //depot/Main/XXX/...@285519
p4 -s -c RBovillTestRelated sync //depot/Main/UnitTestData/...@285519
ECHO ========== Building XXX ==========
CALL bin\VSXXX.bat -rebuild -debug -nopause
ECHO ========== Finished ==========
PAUSE

No comments: