Application of Batch Processing

Source: Internet
Author: User

1. Xcopy deploymentProgram.

The files include deploy. BAT and config.txt.
Deploy. Bat reads the configuration information of config.txt and uses xcopy to deploy the program.
Config.txt saves the configuration parameter information.
File Content:

Config.txt:

D: \ mywork \ localweb
D: \ develop \ source \ jtgl
*. Aspx, *. JS, *. asp, *. html, *. htm, *. jpg, *. CSS, *. GIF, *. XML, *. ascx
*. Aspx, *. js

Parameter description of each row: the first line: the folder to be deployed
Row 2: folders in the Development Environment
Row 3: Suffix of the file to be copied
Row 4: The suffix of the saved copy file.
Deploy. BAT:

@ Echo off
Echo.
Echo starts to detect the system'sCodePath and website installation path ......
Setlocal enabledelayedexpansion
Set IPOs = 0

: Get the configuration information in cofig, which is not flexible.

For/F % I in (config.txt) Do (
Set/A IPOs + = 1
If! IPOs! Equ 1 Set gspos = % I
If! IPOs! Equ 2 set sourcepos = % I
If! IPOs! Equ 3 set total = % I
If! IPOs! Equ 4 set quick = % I
)
Echo.
Echo obtains the website installation path: % gspos %
Echo.
Echo acquisitionSource codePath: % sourcepos %
Echo.
Echo starts configuring the website ......
Echo.
Echo starts to configure the assembly .....
Echo.

: Delete an assembly
Del % gspos % \ bin \ XXX. dll
: Assembly to be deleted

: Copy assembly
Copy % sourcepos % \ public_com \ bin \ debug \ XXX. dll % gspos % \ bin
: Assembly to be copied
Echo.

Select the configuration method for choice/C: 12/M (1: Quick configuration, 2: Full configuration)

: Complete configuration. configure all suffix files set in the third row of config.txt.
If errorlevel = 2 call;: copyfile; % Total %

: For fast configuration, configure all suffix files set in the fourth row of config.txt.
If errorlevel = 1 call;: copyfile; % quick %
Goto end

: The subroutine of the copied file.
: Copyfile
: Begin
If "% 1" = "" Exit/B
Xcopy % sourcepos % \ % 1% gspos % \ jtgl \/S/R/y
Shift
Goto begin
: End
Echo.
Echo began to clear the IE cache file .....

: Clear the cache. I don't know why, no matter what it is !! Depressed!
: Del/f/S/Q "% USERPROFILE % \ Local Settings \ Temporary Internet Files \*.*"

Echo.
Echo cleared ie cache!
Echo.
: Pause

2. Execute SQL statements in batches.

Replace the parameters in the specified file. In this example, replace @ yr @ with 2007 @

Execsql. BAT file content:

@ Echo off
: Set the directory where the SQL file is located
Setlocal enabledelayedexpansion
Set sqlpos = D: \ develop \ source \ SQL
MD c: \ Temp> NUL 2> NUL
: All TXT and SQL files under the directory are saved to list.txt temporarily.
DIR/O: N/B % sqlpos % \ *. txt> list.txt
DIR/O: N/B % sqlpos % \ *. SQL> list.txt

: Execute the SQL statement
for/F % I in (list.txt) Do (
echo.
echo.
ECHO: % I
echo.
echo.
copy/B % sqlpos % \ % I c: \ temp \ tempsql.txt
call;: replace
:: after logging on to sqlserver U, the user name P and the password D are followed by the database name
iSQL-USA-pmyvpass-dmydatabase-ic: \ temp \ tempsql_tmp.txt
quit> NUL 2> NUL
del C: \ temp \ tempsql.txt
del c: \ temp \ tempsql_tmp.txt
echo.
echo.
the SQL statement executed by ECHO is complete!
echo.
echo.
)
Del list.txt
goto end

: Replace
For/F "delims =" % A in ('Type c: \ temp \ tempsql.txt ') Do (
Set STR = %
Set "str =! STR: @ yr @ = 2007! "
Echo! Str!> C: \ temp \ tempsql_tmp.txt
)
Exit/B
: End

Pause

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.