当前位置:文档之家› Estimates for parameters and characteristics of the confining SU(3)-gluonic field in pions

Estimates for parameters and characteristics of the confining SU(3)-gluonic field in pions

Estimates for parameters and characteristics of the confining SU(3)-gluonic field in pions
Estimates for parameters and characteristics of the confining SU(3)-gluonic field in pions

a r X i v :h e p -p h /0609135v 1 14 S e p 2006Estimates for parameters and characteristics of the con?ning SU(3)-gluonic ?eld in pions

and kaons

Yu.P.Goncharov

Theoretical Group,Experimental Physics Department,State Polytechnical

University,Sankt-Petersburg 195251,Russia

1Introduction and preliminary remarks

In Ref.[1]for the Dirac-Yang-Mills system derived from QCD-Lagrangian there was found a family of compatible nonperturbative solutions which could pretend to decsribing con?nement of two quarks.Further study of this family as well as its applications to the quarkonia spectra (charmonium and bot-tomonium)in Refs.[2,3]showed that the above family is in essence unique one [4]and allows one to modify gluon propagator in a nonperturbative way so that the modi?ed propagator could correspond to linear con?nement at large distances [5].

Two main physical reasons for linear con?nement in the mechanism under discussion are the following ones.The ?rst one is that gluon exchange between quarks is realized with the propagator di?erent from the photon one and existence of such a propagator is direct consequence of the unique con?ning nonperturbative solutions of the Yang-Mills equations [4].The second reason

is that,owing to the structure of mentioned propagator,gluon condensate (a classical gluon?eld)between quarks mainly consists of soft gluons(for more details see[4,5])but,because of that any gluon also emits gluons(still softer),the corresponding gluon concentrations rapidly become huge and form the linear con?ning magnetic colour?eld of enormous strengths which leads to con?nement of quarks.Under the circumstances physically nonlinearity of the Yang-Mills equations e?ectively vanishes so the latter possess the unique nonperturbative con?ning solutions of the abelian-like form(with the values in Cartan subalgebra of SU(3)-Lie algebra)[4]that describe the gluon condensate under consideration.Moreover,since the overwhelming majority of gluons are soft they cannot leave hadron(meson)until some gluon obtains additional energy(due to an external reason)to rush out.So we deal with con?nement of gluons as well.

The approach under discussion equips us with the explicit wave functions that is practically unreachable in other approaches,for example,within framework of lattice theories or potenial https://www.doczj.com/doc/8d18627593.html,ly,for each two quarks(me-son)there exists its own set of real constants(for more details see below) a j,A j,b j,B j parametrizing the mentioned nonperturbative con?ning gluon?eld (the gluon condensate)and the corresponding wave functions(nonperturba-tive modulo square integrable solutions of the Dirac equation in this con?n-ing SU(3)-?eld)while the latter ones also depend onμ0,the reduced mass of the current masses of quarks forming meson.It is clear that constants a j,A j,b j,B j,μ0should be extracted from experimental data.This circum-stance gives possibilities for direct physical modelling of internal structure for any meson and for checking such relativistic models numerically.

So far all applications of the con?nement mechanism under consideration have been restricted to the quarkonia[2–5].The aim of the present paper is to estimate the above parameters for the case of pions and kaons.Of course, when conducting our considerations we should rely on the standard quark model(SQM)based on SU(3)-?avor symmetry(see,e.g.,Ref.[6]or the oldies [8]).

Further we shall deal with the metric of the?at Minkowski spacetime M that we write down(using the ordinary set of local spherical coordinates r,?,?for the spatial part)in the form

ds2=gμνdxμ?dxν≡dt2?dr2?r2(d?2+sin2?d?2).(1) Besides,we have|δ|=|det(gμν)|=(r2sin?)2and0≤r<∞,0≤?<π, 0≤?<2π.

Throughout the paper we employ the Heaviside-Lorentz system of units with ˉh=c=1,unless explicitly stated otherwise,so the gauge coupling constant g and the strong coupling constantαs are connected by relation g2/(4π)=αs.

Further we shall denote L2(F)the set of the modulo square integrable complex functions on any manifold F furnished with an integration measure,then L n2(F)will be the n-fold direct product of L2(F)endowed with the obvious scalar product while?and?stand,respectively,for Hermitian and complex conjugation.Our choice of Diracγ-matrices conforms to the so-called standard representation and is

γ0= 100?1 ,γb= 0σb

?σb0

,b=1,2,3,α=γ0γ= 0σσ0 ,(2)

whereσb denote the ordinary Pauli matrices andσ=σ1i+σ2j+σ3k.At last ?means tensorial product of matrices and I3is the unit3×3matrix. When calculating we apply the relations1GeV?1≈0.1973269679fm,1s?1≈0.658211915×10?24GeV,1V/m≈0.2309956375×10?23GeV2,1T≈0.6925075988×10?15GeV2.

Finally,for the necessary estimates we shall employ the T00-component(volu-metric energy density)of the energy-momentum tensor for a SU(3)-Yang-Mills ?eld which should be written in the chosen system of units in the form

Tμν=?F aμαF aνβgαβ+

1

√r+A1,?A3t+13A8t=?a2√r?(A1+A2),

A3?+1

3

A8?=b1r+B1,?A3?+

1

3

A8?=b2r+B2,?

2

3

A8?=?(b1+b2)r?(B1+B2)

(4)

with the real constants a j,A j,b j,B j parametrizing the family.

Another part of the family is given by the unique nonperturbative modulo square integrable solutions of the Dirac equation in the con?ning SU(3)-?eld of

(4)Ψ=(Ψ1,Ψ2,Ψ3)with the four-dimensional Dirac spinorsΨj representing the j th colour component of the meson,which may describe the relativistic bound states of two quarks(mesons)and look as follows(with Pauli matrix σ1)

Ψj=e iωj t r?1 F j1(r)Φj(?,?)

F j2(r)σ1Φj(?,?) ,j=1,2,3(5) with the2D eigenspinorΦj= Φj1Φj2 of the euclidean Dirac operator D0on the unit sphere S2,while the coordinate r stands for the distance between quarks.The explicit form ofΦj is not needed here and can be found in Ref. [5,7].For the purpose of the present Letter we shall adduce the necessary spinors below.SpinorsΦj form an orthonormal basis in L22(S2).

The energy spectrum of a meson is given byω=ω1+ω2+ω3with

ωj=ωj(n j,l j,λj)=gA j+

?Λj g2a j b j±(n j+αj) n2j+2n jαj+Λ2j,j=1,2,3,

(6) where g is the gauge coupling constant,a3=?(a1+a2),b3=?(b1+b2),A3=?(A1+A2),B3=?(B1+B2),Λj=λj?gB j,αj=

βj ,P j=gb j+βj,

F j2=iC j Q j rαj e?βj r 1+gb j

μ20?ω2j+g2b2j while C j is determined from the normalization con-dition ∞0(|F j1|2+|F j2|2)dr=1

ˉh c,a j→a j/√ˉh c,

B j→B j/√

2ˉh2(n j+|λj|)2z2 ? λg2a j b jˉh3(n

j

+|λj|)7

z+O(z2),

(8)

where f(n j,λj)=4λj n j(n2j+λ2j)+|λj|

μ20+g2b2j.

We may seemingly use(6)with various combinations of signes(±)before sec-ond summand in numerators of(6)but,due to(8),it is reasonable to take all signs equal to+which is our choice within the Letter.Besides,as is not com-

plicated to see,radial parts in nonrelativistic limit have the behaviour of form F j1,F j2~r l j,which allows one to call quantum number l j angular momentum for j th colour component though angular momentum is not conserved in the

?eld(4)[1,5].So for mesons under consideration we should put all l j=0. Finally it should be noted that spectrum(6)is degenerated owing to degen-eracy of eigenvalues for the euclidean Dirac operator D0on the unit sphere https://www.doczj.com/doc/8d18627593.html,ly,each eigenvlalue of D0λ=±(l+1),l=0,1,2...,has multiplicity 2(l+1)so we has2(l+1)eigenspinors orthogonal to each other.Ad referen-dum we need eigenspinors corresponding toλ=±1(l=0)so here is their explicit form

λ=?1:Φ=C2

e?i?2 e i?2

e?i?/2,

λ=1:Φ=C2

e i?2 ?e?i?2

e?i?/2(9)

with the coe?cient C=1/

μ=

3

j=1ωj(0,0,λj)=3 j=1 ?g2a j b j|Λj| (10)

and,as a consequence,the corresponding meson wave functions of(5)are represented by(7),(9).

3.1Choice of quark masses and gauge coupling constant

It is evident for employing the above relations we have to assign some values

to quark masses and gauge coupling constant g.In accordance with Ref.[6], at present the current quark masses are restricted to intervals1.5MeV≤

m u≤5MeV,3.0MeV≤m d≤9MeV,60MeV≤m s≤170MeV,so we take m u=(1.5+5)/2MeV=3.25MeV,m d=(3+9)/2MeV=6MeV,

m s=(60+170)/2MeV=115MeV.Under the circumstances,the reduced

massμ0of Table1will respectively take values m u/2,m d/2,m u m d/(m u+

m d),m u m s/(m u+m s),m d m s/(m d+m s).As to gauge coupling constant g=√

Ψ(γμ?I3)Ψ=(Ψ?Ψ,Ψ?(α?I3)Ψ)=(ρ,J).Electric formfactor f(K)is the Fourier transform ofρ

f(K)= Ψ?Ψe?i Kr d3x=3 j=1 Ψ?jΨj e?i Kr d3x=3 j=1f j(K)= 3

j=1 (|F j1|2+|F j2|2)Φ?jΦj e?i Kr

αΓ(α), π0e ?iKr cos ?sin ?d?=2sin (Kr )/(Kr ),we shall obtain

f (K )=3 j =1f j (K )=

3 j =1(2βj )2αj +1K (K 2+4β2j

)αj =

3 j =1 16β2j ·K 2

3 j =12α2j

+3αj +1 r 2Ψ?Ψd 3x =

r 2d 3

x,J y =3 j =1 (F ?j 1F j 2?F ?j 2F j 1)Φ?j

σ2σ1Φj r 2

d 3x.(14)

Magnetic moment of meson is M = V m d 3x ,where V is volume of meson.Then at l j =0we have J y =0for any spinor of (9),while V m x,y,z d 3x =0

because of turning to zero either integral over ?or the one over ?,which is

easily to check.As a result,magnetic moments of mesons under consideration

with the wave functions of (5)(at l j =0)are equal to zero,as should be

according to experimental data [6].

3.4Numerical results

We employed relations(10)and(13)for obtaining estimates of the con?ning

SU(3)-gluonic?eld parameters in mesons under discussion and,to impose

more restrictions,we considered in(10)eachωj=μ/3,μis meson mass,

though it is not obligatory.Also the experimental estimates,if any,of

were used from Refs.[6,11].The results are adduced in Tables1,2.It should

be noted that in accordance with SQM[8]π0=(dd)/

uu and

g a1b1(GeV)B1

π0— 6.2816-0.0124758-0.2754160.3385

π0— 6.28160.01215240.2737830.3385

π±—u ud 2.108110.0128925-0.273365-0.3385 s, 6.12560.03483550.5245850.5303

K0,s, 6.114970.04948560.1043980.36052

Theoret.(MeV)Theoret.(fm)π0—μ=ω1(0,0,?1)+ω2(0,0,?1)+ω3(0,0,?1)=134.9760.602594

π0—μ=ω1(0,0,?1)+ω2(0,0,?1)+ω3(0,0,?1)=134.9760.606236

π±—u ud139.569950.6050 s,μ=ω1(0,0,?1)+ω2(0,0,?1)+ω3(0,0,?1)=493.6770.564046

K0,s,μ=ω1(0,0,1)+ω2(0,0,1)+ω3(0,0,1)=497.6720.560964

the?eld(4)with the3-dimensional SU(3)-Lie algebra valued1-forms of electric

E and magnetic H colour?elds and also with T00-component(volumetric energy density)of the energy-momentum tensor(3)

E= λ3(a1?a2)+λ8(a1+a2)√2r2,H=? λ3(b1?b2)+λ8(b1+b2)√2sin?,

(15)

T00≡T tt=1r4+b21+b1b2+b22r4+B

G(E,E)= r2,H= b21+b1b2+b22

Γ

(18)

so we can rewrite(16)in the form T00=T coul

00+T lin00conforming to the con-

tributions from the Coulomb and linear parts of the solution(4).The latter gives the corresponding split of n from(18)as n=n coul+n lin.

The parameters of Tables1,2were employed when computing and for simplic-ity we put sin?=1in(16)–(17).Also there were used the following present-day whole decay widths of mesons under consideration[6]:Γ=1/τwith the life timesτ=8.4×10?17s,2.6033×10?8s,1.2386×10?8s,0.8953×10?10s (K0S-mode),5.18×10?8s(K0L-mode),respectively,whereas the Bohr radius a0=0.529177249·105fm[6].At last,as has been discussed in Refs.[3,5],we can estimate the quark velocities in the mesons under exploration from the condition

v q=

1

1+ λB

Gluon concentrations,electric and magnetic colour?eld strengths in pions.

π0—

r n coul n lin n E H

(fm)(m?3)(m?3)(m?3)(V/m)(T)

r00.172647×10530.142633×10550.144359×10550.768576×10210.118089×1015 10r00.172647×10490.142633×10530.142650×10530.768576×10190.118089×1014 dd:r0==0.606236fm,v d=0.999080

0.1r00.159916×10570.139255×10570.299171×10570.739697×10230.116682×1016

1.00.216003×10520.511791×10540.513951×10540.271855×10210.707369×1014

a00.275458×10330.182764×10450.182764×10450.970811×10110.133673×1010π±—u ud:r0==0.607418fm,v u=0.999500,v d=0.999078

0.1r00.553136×10650.428537×10650.981673×10650.781449×10230.116271×1016

1.00.752978×10600.158112×10630.158865×10630.288321×10210.706251×1014

a00.960236×10410.564627×10530.564627×10530.102961×10120.133462×1010 5Discussion and concluding remarks

5.1Discussion

As is seen from Tables3,4,at the characteristic scales of each meson the gluon concentrations are large and the corresponding?elds(electric and mag-

Gluon concentrations,electric and magnetic colour?eld strengths in kaons.

K±—u us:r0==0.564046fm,v u=0.999536,v s=0.983958

0.1r00.699798×10660.835931×10650.783392×10660.402965×10240.235429×1016

1.00.708323×10610.265950×10630.273033×10630.128203×10220.132793×1015

a00.903288×10420.949724×10530.949724×10530.457820×10120.250942×1010 K0,s,

r n coul n lin n E H

(fm)(m?3)(m?3)(m?3)(V/m)(T)

r00.377302×10600.148175×10610.185905×10610.348022×10220.116585×1015 10r00.377302×10560.148175×10590.148553×10590.348022×10200.116585×1014–mode):r0==0.560964fm,v d=0.999148,v s=0.984044

K0—d ds(K0

L

0.1r00.218299×10670.857308×10650.226872×10670.348022×10240.116585×1016

1.00.216168×10620.269778×10630.291395×10630.109516×10220.654000×1014

a00.275668×10430.963395×10530.963395×10530.391088×10120.123588×1010 netic colour ones)can be considered to be the classical ones with enormous

strenghts.The part n coul of gluon concentration n connected with the Coulomb

electric colour?eld is decreasing faster than n lin,the part of n related to the

linear magnetic colour?eld,and at large distances n lin becomes dominant

while quarks in mesons under investigation should be considered the ultrarel-

ativistic point-like particles.It should be emphasized that in fact the gluon concentrations are much greater than the estimates given in Tables3,4be-

cause the latter are the estimates for maximal possible gluon frequencies,i.e.

for maximal possible gluon impulses(under the concrete situation of pions and kaons).The latter also explains why gluon concentrations are much larger

(about8orders of magnitude)for charged pions compared toπ0-meson:just the corresponding life times are di?erent by the same orders so,accordingly,

the conforming maximal gluon impulses are in inverse relation.

The given picture is in concordance with the one obtained when considering charmonium in Refs.[2,3,5].As a result,the con?nement mechanism developed in Refs.[1,4,5]is con?rmed by the considerations of the present Letter.

It should be noted,however,that our results are of a preliminary character

which is readily apparent,for example,from that the current quark masses(as well as the gauge coupling constant g)used in computation are known only within the certain limits and we can expect similar limits for the magnitudes

discussed in the Letter so it is neccesary further speci?cation of the parameters for the con?ning SU(3)-gluonic?eld in pions and kaons which can be obtained,

for instance,by calculating decay constants and weak formfactors for the given mesons with the help of wave functions discussed above.Also one can obtain the analogous estimates for vector mesons,for instance,by computing the

widths of radiative decays for them and so on.We hope to continue analysing other problems of meson spectroscopy elsewhere.

5.2Connection with potential approach and string-like picture

The results obtained above allow us to shed some light on the following two problems.As is known,during a long time up to now in meson spectroscopy

one often uses the so-called potential approach(see,e.g.,Refs.[12,13]and references therein).The essence of it is in that the interaction between quarks is modelled on a nonrelativistic con?ning potential in the form a/R+kR+c0

with some real constants a,k,c0and the distance between quarks R.On the other hand,also for a long time there exists the so-called string-like picture

of quark con?nement but only at qualitative level(see,e.g.,book of Perkins in[8]).Up to now,however,it is unknown as such considerations might be warranted from the point of view of QCD.Let us in short outline as our

results(based on and derived from QCD-Lagrangian directly)naturally lead to possible justi?cation of the mentioned directions.Thereto we note that one

can calculate energy E of gluon condensate conforming to solution(4)in a volume V through relation E= V T00r2sin?drd?d?with T00of(16)–(17) but one should take into account that classical T00has a singularity along

z-axis(?=0,π)and we have to introduce some angle?0(whose physical meaning is to be clari?ed a little below)so?0≤?≤π??0.Then let us choose V as shown in Fig.1,i.e.the one between two concentric spheres with

radii R0

Fig.1.Integration domain for obtaining the gluonic energy

Without going into details(see also Ref.[4])we shall obtain

E=E(R)=E0+a

R0?2πB R0ln1+cos?01?cos?0 with constants A,B of(16).We recognize the mentioned con?ning poten-

tial in(20)when identifying E0=c0and we can see that phenomenological parameters a,k,c0of potential are expressed through more fundamental pa-rameters connected with the unique exact solution(4)of Yang-Mills equations describing con?nement.One can notice that the quantity k(string tension) is usually related to the so-called Regge slopeα′=1/(2πk)and in many if not all of the papers using potential approach it is accepted k≈0.18 GeV2,E0=c0≈?0.873GeV(see,e.g.,Refs.[12,13]).Also one often uses parametrization a=?4αs(R0)/3,whereαs(R0)is the strong coupling con-stant at R0so when R

Table5

Parameters determining the con?ning potential for pions,kaons and charmonium ground state.

Particleαs(R0)

π0—64.56?0.757

dd0.532×10?3

π±—u ud0.600×10?3

K±—u us0.357×10?2

K0,s,60.272?0.960

c0.163×10?2

Fig.2.Formation of string-like picture between quarks

system when inserting potential of form(20)into Dirac(Pauli,Schr¨o dinger) equation.So,we draw the conclusion(mentioned as far back as in Refs.[2]) that the potential approach seems to be inconsistent.

Now if there are two quarks Q1,Q2and each of them emits gluons outside of its own cone?=?1,2(see Fig.2)then we have soft gluons(as mentioned in Section1)in regions I,II and between quarks so a characteristic transverse size D of the gluon condensate is decreasing with increasing quark masses as we just now saw.For heavy quarks the gluon con?guration between them practically transforms into a string.As a result,there arises the string-like picture of quark con?nement but the latter seems to be warranted enough only for heavy quarks.It should be emphasized that string tension k is determined just by parameters b1,2of linear magnetic colour?eld from solution(4)[see (20)]which indirectly con?rms the dominant role of the mentioned?eld for con?nement.

5.3Concluding remarks

Considerations of the present Letter as well as ones of Refs.[2,3]show that in meson spectroscopy the approach based on the unique family of compatible nonperturbative solutions for the Dirac-Yang-Mills system derived from QCD-Lagrangian may be employed for both light mesons and heavy quarkonia. Under the circumstances there are no apparent obstacles to apply the approach to any meson.We hope further studies along this direction to con?rm the given point of view.

Acknowledgements

Author is grateful to the referee whose valuable remarks promoted essential improvement of the initial version of the Letter.

References

[1]Yu.P.Goncharov,Mod.Phys.Lett.A16(2001)557.

[2]Yu.P.Goncharov,Europhys.Lett.62(2003)684;

Yu.P.Goncharov and E.A.Choban,Mod.Phys.Lett.A18(2003)1661.

[3]Yu.P.Goncharov and A.A.Bytsenko,Phys.Lett.B602(2004)86.

[4]Yu.P.Goncharov,Phys.Lett.B617(2005)67.

[5]Yu.P.Goncharov,in:New Developments in Black Hole Research,ed.P.V.

Kreitler(Nova Science Publishers,Inc.,New York,2006),Chapter3,pp.67–121(hep-th/0512099).

[6]S.Eidelman,et al.,Particle Data Group,Phys.Lett.B592(2004)1.

[7]Yu.P.Goncharov,Pis’ma v ZhETF69(1999)619;

Phys.Lett.B458(1999)29.

[8]Yu.B.Rumer,A.I.Fet,Theory of Unitary Symmetry,Nauka,Moscow,1970;

F.E.Close,An Introduction to Quarks and Partons,Academic Press,London,

1979;

D.H.Perkins,Introduction to High Energy Physics,Addison–Wesley,London,

1987.

[9] A.Deur,Nucl.Phys.A755(2005)353;

A.Deur,et.al.,hep-ph/0509113.

[10]A.P.Prudnikov,Yu.A.Brychkov and O.I.Marichev,Integrals and Series.

Elementary Functions(Nauka,Moscow,1981).

[11]R.Alkofer,A.Bender,C.D.Roberts,Int.J.Mod.Phys.A10(1995)3319;

B.V.Geshkenbein,Phys.Rev.D61(2000)033009.

[12]W.Roberts,B.Silvestre-Brac,Phys.Rev.D57(1998)1694;

R.Bonnaz,B.Silvestre-Brac and C.Gignoux,Eur.Phys.J.A13(2002)363.

[13]N.Brambilla,et al.,CERN Yellow Report,CERN-2005-005Geneva:CERN,

2005(hep-ph/0412158).

批处理命令行for语句

for语句可以在命令行提示符中使用,也可以在批处理文件中使用。这两种情况下唯一的区别是%和%%,参加下文说明。 一、for语句的格式: for [参数] 变量in (集合) do 命令[命令的参数] 二、for语句的作用:对集合内的元素逐一执行后面的命令。 1、如:for %%i in (你好) do echo %%i 将在屏幕上显示“你好”2个字。这里集合是“你好”,执行的命令是“echo”。由于集合中只有1个元素,因此循环只运行一次。 如果改成for %%i in (你好朋友) do echo %%i 将会显示2行文字,第一行为“你好”,第二行为“朋友”。因为2个词之间有空格,因此集合中就有了2个元素,循环将运行2次。 2、注意:以上for语句的运行方式是新建一个批处理文件,即扩展名为“.bat”的文件,内容为上面的命令,然后运行。为了批处理执行完不退出,可在最后加上一条pause>null命令,这样能看到执行的结果。要想通过cmd命令行执行的话,必须将%%换成%,即去掉一个%,如下: for %i in (你好) do echo %i 3、以下所有例子都是这样,若要在命令行提示符下执行,请将所有的%%改成一个%。 三、for语句详细说明: 上面语句格式中有的加了中括号[],表示这个语句元素不是必须的,只在需要时使用。像刚才显示“你好”的命令中就没有使用[参数]这

个语句元素。所有语句元素间用空格隔开。 各语句元素的写法:for、in、do这3个符号是固定不变的 1、[参数]的种类:只有4种,分别是/d、/r、/l、/f(即目录Directory、递归recursion、序列list、文件file),他们用于对后面的集合的含义做出解释,请与下面的集合解释结合来看。这4个参数不区分大小写,可以联合使用,即一条for语句可以出现多个参数。 2、变量:除10个数字外(0-9)的所有符号(因为0-9往往作为形参使用,为了与此区别),变量名一般用单个字母表示即可,而且变量名区分大小写,即A和a是两个不同的变量。变量名前面必须是%,当在命令提示符下执行时,只用一个%;而在批处理程序中,必须用%%。 一行语句中,一般只需定义一个变量。使用/f参数中的tokens 选项可以将集合中的元素分解成多个值,并自动定义新的变量对应这些值。这时语句中可以使用多个变量,通常按字母顺序命名,即第一个是%%a,那么后一个就用%%b。如果第一个是%%i,后一个就用%%j。依此类推。具体看后面的相关内容。 变量可以直接在do后面的命令中使用。每次使用的变量总数不超过52个。 3、集合:集合必须放在括号里。集合是一行文本,这行文本可能有几种类型,如“你好”只是一串字符;“c:\boot.ini”是一个文件;“dir /b”是一个命令。 (1)如果for语句中没有使用任何参数,对待集合文本的处理方式是:

批处理命令for语句基本用法

批处理命令for语句的基本用法 [系列教程]批处理for语句从入门到精通[20101225更新] ____________________________版主提醒 ____________________________ 文档来自于网络搜索 为了避免影响技术讨论、提高看帖的舒适性,请大家不要在此帖下跟 无实质内容的口水帖,特别是纯顶、纯支持、纯感谢、路过之类的帖子, 管理人员将不定期清理此类回帖,请大家多参与讨论少灌水,与人方便, 终将给自己带来方便,谢谢合作。 ________________________________________________________________ 文档来自于网络搜索 批处理是一门简单的脚本语言,虽然不能独当一面,但是,若作为工作中的辅助工具,绝对会让大家有随用随写、称心如意的畅快感。 文档来自于网络搜索 和其他语言相比,批处理语言有其先天性的优势: 1、系统自带,无需另行安装; 2、命令少,语句简洁,上手非常快; 3、编写出来的脚本小巧玲珑,随写随用; 但是,因为它以命令行方式工作,操作多有不便,在图形界面大行其道的windows世界里,多多少少会让大众望而却步;就算是对命令行有好感的新手,面对微软有如天书的帮助文件,很多人也会败下阵来,因此,论坛里很多会员也发出了编写系统的批处理教程的呼声。

文档来自于网络搜索 编写系统的批处理新手教程,一直是论坛管理层讨论的热点问题,但是,各位管理人员大多都有工作在身,而系统的教程涉及的面是如此之广,面对如此浩大的工程,仅凭一两个人的力量,是难以做好的,因此,本人退而求其次,此次发布的教程,以专题的形式编写,日后人手渐多之后,再考虑组织人力编写全面的教程。 文档来自于网络搜索之所以选择最难的for,一是觉得for最为强大,是大多数人最希望掌握的;二是若写其他命令教程,如果没有for的基础,展开来讲解会无从下手;三是for也是批处理中最复杂最难掌握的语句,把它攻克了,批处理的学习将会一片坦途。 文档来自于网络搜索 这次的for语句系列教程,打算按照for语句的5种句式逐一展开,在讲解for/f的时候,会穿插讲解批处理中一个最为关键、也是新手最容易犯错的概念:变量延迟,大纲如下: 文档来自于网络搜索一前言 二for语句的基本用法 三for /f(含变量延迟) 四for /r 五for /d 六for /l 遵照yibantiaokuan的建议,在顶楼放出此教程的txt版本、word版本和pdf版本,以方便那些离线浏览的会员。 文档来自于网络搜索[本帖最后由namejm于2010-12-26 02:36编辑]

实用批处理(bat)教程

目录 第一章批处理基础 第一节常用批处理内部命令简介 1、REM 和:: 2、ECHO 和@ 3、PAUSE 4、ERRORLEVEL 5、TITLE 6、COLOR 7、mode 配置系统设备 8、GOTO 和: 9、FIND 10、START 11、assoc 和ftype 12、pushd 和popd 13、CALL 14、shift 15、IF 16、setlocal 与变量延迟(ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION 启动或停用延缓环境变量扩展名。) 17、ATTRIB显示或更改文件属性 第二节常用特殊符号 1、@命令行回显屏蔽符 2、%批处理变量引导符 3、> 重定向符 4、>>重定向符 5、<、>、<& 重定向符 6、|命令管道符 7、^转义字符 8、组合命令 9、& 组合命令 10、||组合命令 11、\"\"字符串界定符 12、, 逗号 13、; 分号 14、() 括号 15、! 感叹号 第二章FOR命令详解 一、基本格式 二、参数/d仅为目录 三、参数/R递归(文件名) 四、参数/L迭代数值范围 五、参数/F迭代及文件解析 第三章FOR命令中的变量

一、~I- 删除任何引号(\"),扩展%I 二、%~fI- 将%I 扩展到一个完全合格的路径名 三、%~dI- 仅将%I 扩展到一个驱动器号 四、%~pI- 仅将%I 扩展到一个路径 五、%~nI- 仅将%I 扩展到一个文件名 六、%~xI- 仅将%I 扩展到一个文件扩展名 七、%~sI- 扩展的路径只含有短名 八、%~aI- 将%I 扩展到文件的文件属性 九、%~tI- 将%I 扩展到文件的日期/时间 十、%~zI- 将%I 扩展到文件的大小 十一、%~$PATH:I 第四章批处理中的变量 一、系统变量 二、自定义变量 第五章set命令详解 一、用set命令设置自定义变量 二、用set命令进行简单计算 三、用set命令进行字符串处理 1、字符串替换 2、字符串截取 第六章if命令讲解 第一种用法:IF [NOT] ERRORLEVEL number command 第二种用法:IF [NOT] string1==string2 command 第三种用法:IF [NOT] EXIST filename command 第四种用法:IF增强的用法 第七章DOS编程高级技巧 一、界面设计 二、if…else…条件语句 三、循环语句 四、子程序 五、用ftp命令实现自动下载 六、用7-ZIP实现命令行压缩和解压功能 七、调用VBScript程序 八、将批处理转化为可执行文件 九、时间延迟 1、利用ping命令延时 2、利用for命令延时 3、利用vbs延迟函数,精确度毫秒,误差1000毫秒内 4、仅用批处理命令实现任意时间延迟,精确度10毫秒,误差50毫秒内 十、模拟进度条 十一、特殊字符的输入及应用 十二、随机数(%random%)的应用技巧 十三、变量嵌套与命令嵌套 1、更正了所有的错别字,适当排版,增加条理性。

批处理内部命令简介

一.简单批处理内部命令简介 1.Echo 命令 打开回显或关闭请求回显功能,或显示消息。如果没有任何参数,echo命令将显示当前回显设置。 语法 echo [{on off}] [message] Sample:@echo off / echo hello world 在实际应用中我们会把这条命令和重定向符号(也称为管道符号,一般用>>>^)结合来实现输入一些命令到特定格式的文件中.这将在以后的例子中体现出来。 2.@ 命令 表示不显示@后面的命令,在入侵过程中(例如使用批处理来格式化敌人的硬盘)自然不能让对方看到你使用的命令啦。 Sample:@echo off @echo Now initializing the program,please wait aminite... @format X: /q/u/autoset (format这个命令是不可以使用/y这个参数的,可喜的是微软留了个autoset这个参数给我们,效果和/y是一样的。) 3.Goto 命令 指定跳转到标签,找到标签后,程序将处理从下一行开始的命令。 语法:goto label(label是参数,指定所要转向的批处理程序中的行。) Sample: if {%1}=={} goto noparms if {%2}=={} gotonoparms(如果这里的if、%1、%2你不明白的话,先跳过去,后面会有详细的解释。) @Rem check parameters if null show usage

:noparms echo Usage: monitor.bat ServerIP PortNumber goto end 标签的名字可以随便起,但是最好是有意义的字母啦,字母前加个:用来表示这个字母是标签,goto 命令就是根据这个:来寻找下一步跳到到那里。最好有一些说明这样你别人看起来才会理解你的意图啊。 4.Rem 命令 注释命令,在C语言中相当与/*--------*/,它并不会被执行,只是起一个注释的作用,便于别人阅读和你自己日后修改。 Rem Message Sample:@Rem Here is the description. 5.Pause 命令 运行Pause 命令时,将显示下面的消息: Press any key to continue . . . Sample: @echo off :begin copy a:*.* d:\back echo Please put a new disk into driver A pause goto begin 在这个例子中,驱动器A中磁盘上的所有文件均复制到d:\back中。显示的注释提示您将另一张磁盘放入驱动器A 时,pause命令会使程序挂起,以便您更换磁盘,然后按任意键继续处理。

批处理基础知识

批处理文件基础知识 一、单符号message指定让MS-DOS在屏幕上显示的正文 ~ ①在for中表示使用增强的变量扩展。 ②在%var:~n,m%中表示使用扩展环境变量指定位置的字符串。 ③在set/a中表示一元运算符,将操作数按位取反。 ! ①在set /a中一元运算符,表示逻辑非。比如set /a a=!0,这时a就表示逻辑1。 @ ①隐藏命令行本身的回显,常用于批处理中。 % ①在set /a中的二元运算符,表示算术取余。 ②命令行环境下,在for命令in前,后面接一个字符(可以是字母、数字或者一些特定字符),表示指定一个循环或者遍历指标变量。 ③批处理中,后接一个数字表示引用本批处理当前执行时的指定的参数。 ④其它情况下,%将会被脱去(批处理)或保留(命令行) ^ ①取消特定字符的转义作用,比如& | > < ! "等,但不包括%。比如要在屏幕显示一些特殊的字符,比如> >> | ^ &等符号时,就可以在其前面加一个^符号来显示这个^后面的字符了,^^就是显示一个^,^|就是显示一个|字符了; ②在set/a中的二元运算符,表示按位异或。 ③在findstr/r的[]中表示不匹配指定的字符集。 & ①命令连接字符。比如我要在一行文本上同时执行两个命令,就可以用&命令连接这两个命令。 ②在set/a中是按位与。 : ①标签定位符,表示其后的字符串为以标签,可以作为goto命令的作用对象。比如在批处理文件里面定义了一个":begin"标签,用"goto begin"命令就可以转到":begin"标签后面来执行批处理命令了。 ②在%var:string1=string2%中分隔变量名和被替换字串关系。 | ①管道符,就是将上一个命令的输出,作为下一个命令的输入."dir /a/b |more"就可以逐屏的显示dir命令所输出的信息。 ②在set/a中的二元运算符,表示按位或。 ③在帮助文档中表示其前后两个开关、选项或参数是二选一的。 / ①表示其后的字符(串)是命令的功能开关(选项)。比如"dir /s/b/a-d"表示"dir"命令指定的不同的参数。 ②在set/a中表示除法。 > ①命令重定向符,将其前面的命令的输出结果重新定向到其后面的设备中去,后面的设备中的内容被覆盖。比如可以用"dir > lxmxn.txt"将"dir"命令的结果输出到"lxmxn.txt"这个文本文件中去。 ②在findstr/r中表示匹配单词的右边界,需要配合转义字符\使用。 < ①将其后面的文件的内容作为其前面命令的输入。 ②在findstr/r中表示匹配单词的左边界,需要配合转义字符\使用。 . ①在路径的\后紧跟或者单独出现时:

批处理命令格式

批处理命令格式.txt人永远不知道谁哪次不经意的跟你说了再见之后就真的再也不见了。一分钟有多长?这要看你是蹲在厕所里面,还是等在厕所外面……echo 表示显示此命令后的字符 echo off 表示在此语句后所有运行的命令都不显示命令行本身 @与echo off相象,但它是加在每个命令行的最前面,表示运行时不显示这一行的命令行(只能影响当前行)。 call 调用另一个批处理文件(如果不用call而直接调用别的批处理文件,那么执行完那个批处理文件后将无法返回当前文件并执行当前文件的后续命令)。 pause 运行此句会暂停批处理的执行并在屏幕上显示Press any key to continue...的提示,等待用户按任意键后继续 rem 表示此命令后的字符为解释行(注释),不执行,只是给自己今后参考用的(相当于程序中的注释)。 例1:用edit编辑a.bat文件,输入下列内容后存盘为c: a.bat,执行该批处理文件后可实现:将根目录中所有文件写入 a.txt中,启动UCDOS,进入WPS等功能。 批处理文件的内容为: 命令注释: @echo off 不显示后续命令行及当前命令行 dir c: *.* >a.txt 将c盘文件列表写入a.txt call c: ucdos ucdos.bat 调用ucdos echo 你好显示"你好" pause 暂停,等待按键继续 rem 准备运行wps 注释:准备运行wps cd ucdos 进入ucdos目录 wps 运行wps 批处理文件的参数 批处理文件还可以像C语言的函数一样使用参数(相当于DOS命令的命令行参数),这需要用到一个参数表示符“%”。 %[1-9]表示参数,参数是指在运行批处理文件时在文件名后加的以空格(或者Tab)分隔的字符串。变量可以从%0到%9,%0表示批处理命令本身,其它参数字符串用%1到%9顺序表示。例2:C:根目录下有一批处理文件名为f.bat,内容为: @echo off format %1 如果执行C: >f a: 那么在执行f.bat时,%1就表示a:,这样format %1就相当于format a:,于是上面的命令运行时实际执行的是format a: 例3:C:根目录下一批处理文件名为t.bat,内容为: @echo off type %1 type %2 那么运行C: >t a.txt b.txt %1 : 表示a.txt %2 : 表示b.txt 于是上面的命令将顺序地显示a.txt和b.txt文件的内容。 特殊命令 if goto choice for是批处理文件中比较高级的命令,如果这几个你用得很熟练,你就是批

DOS批处理命令大全

写批处理 扩展名是bat(在nt/2000/xp/2003下也可以是cmd)的文件就是批处理文件。 ==== willsort 编注======================================= .bat是dos下的批处理文件 .cmd是nt内核命令行环境的另一种批处理文件 从更广义的角度来看,unix的shell脚本以及其它操作系统甚至应用程序中由外壳进行解释执行的文本,都具有与批处理文件十分相似的作用,而且同样是由专用解释器以行为单位解释执行,这种文本形式更通用的称谓是脚本语言。所以从某个程度分析,batch, unix shell, awk, basic, perl 等脚本语言都是一样的,只不过应用的范围和解释的平台各有不同而已。甚至有些应用程序仍然沿用批处理这一称呼,而其内容和扩展名与dos的批处理却又完全不同。 =================================== 首先批处理文件是一个文本文件,这个文件的每一行都是一条DOS命令(大部分时候就好象我们在DOS 提示符下执行的命令行一样),你可以使用DOS下的Edit或者Windows的记事本(notepad)等任何文本文件编辑工具创建和修改批处理文件。 ==== willsort 题注=================== 批处理文件中完全可以使用非dos命令,甚至可以使用不具有可执行特性的普通数据性文件,这缘于wind ows系统这个新型解释平台的涉入,使得批处理的应用越来越"边缘化"。所以我们讨论的批处理应该限定在dos环境或者命令行环境中,否则很多观念和设定都需要做比较大的变动。 ======================== 其次,批处理文件是一种简单的程序,可以通过条件语句(if)和流程控制语句(goto)来控制命令运行的流程,在批处理中也可以使用循环语句(for)来循环执行一条命令。当然,批处理文件的编程能力与C语言等编程语句比起来是十分有限的,也是十分不规范的。批处理的程序语句就是一条条的DOS命令(包括内部命令和外部命令),而批处理的能力主要取决于你所使用的命令。 ==== willsort 编注================== 批处理文件(batch file)也可以称之为批处理程序(batch program),这一点与编译型语言有所不同,就c语言来说,扩展名为c或者cpp的文件可以称之为c语言文件或者c语言源代码,但只有编译连接后的exe 文件才可以称之为c语言程序。因为批处理文件本身既具有文本的可读性,又具有程序的可执行性,这些称谓的界限是比较模糊的。 =========================== 第三,每个编写好的批处理文件都相当于一个DOS的外部命令,你可以把它所在的目录放到你的DOS搜索路径(path)中来使得它可以在任意位置运行。一个良好的习惯是在硬盘上建立一个bat或者batch目录(例如C:\BATCH),然后将所有你编写的批处理文件放到该目录中,这样只要在path中设置上c:\batch,你就可以在任意位置运行所有你编写的批处理程序。 ==== willsort 编注===== 纯以dos系统而言,可执行程序大约可以细分为五类,依照执行优先级由高到低排列分别是:DOSKEY宏命令(预先驻留内存),https://www.doczj.com/doc/8d18627593.html,中的内部命令(根据内存的环境随时进驻内存),以com为扩

目前为止最全的批处理教程

目录 第一章 批处理基础 第一节 常用批处理内部命令简介 1、REM 和 :: 2、ECHO 和 @ 3、PAUSE 4、ERRORLEVEL 5、TITLE 6、COLOR 7、mode 配置系统设备 8、GOTO 和 : 9、FIND 10、START 11、assoc 和 ftype 12、pushd 和 popd 13、CALL 14、shift 15、IF 16、setlocal 与 变量延迟(ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION 启动或停用延缓环境变量扩展名。) 17、ATTRIB显示或更改文件属性 第二节 常用特殊符号

1、@命令行回显屏蔽符 2、%批处理变量引导符 3、> 重定向符 4、>>重定向符 5、<、>、<& 重定向符 6、|命令管道符 7、^转义字符 8、组合命令 9、& 组合命令 10、||组合命令 11、\"\"字符串界定符 12、, 逗号 13、; 分号 14、() 括号 15、! 感叹号 第二章 FOR命令详解 一、基本格式 二、参数 /d仅为目录 三、参数 /R递归(文件名) 四、参数 /L迭代数值范围 五、参数 /F迭代及文件解析 第三章 FOR命令中的变量

一、 ~I- 删除任何引号(\"),扩展 %I 二、 %~fI- 将 %I 扩展到一个完全合格的路径名 三、 %~dI- 仅将 %I 扩展到一个驱动器号 四、 %~pI- 仅将 %I 扩展到一个路径 五、 %~nI- 仅将 %I 扩展到一个文件名 六、 %~xI- 仅将 %I 扩展到一个文件扩展名 七、 %~sI- 扩展的路径只含有短名 八、 %~aI- 将 %I 扩展到文件的文件属性 九、 %~tI- 将 %I 扩展到文件的日期/时间 十、 %~zI- 将 %I 扩展到文件的大小 十一、 %~$PATH:I 第四章 批处理中的变量 一、系统变量 二、自定义变量 第五章 set命令详解 一、用set命令设置自定义变量 二、用set命令进行简单计算 三、用set命令进行字符串处理 1、字符串替换 2、字符串截取 第六章 if命令讲解 第一种用法:IF [NOT] ERRORLEVEL number command

DOS内部命令和批处理命令列表资料

DOS内部命令和批处理命令列表 Wikipedia,自由的百科全书 MS-DOS 7.1 所有内部命令与批处理命令中文帮助集合 ——本页所有内容均由熊朝伟独自汉化。 命令:CALL 功能:在批处理文件中调用批处理文件. CALL [驱动器:][路径]文件名 [批命令参数] 批命令参数指定批处理文件所需的命令行参数. 命令:CD/CHDIR 功能:显示或改变当前目录. CHDIR [驱动器:][路径] CHDIR[..] CD [驱动器:][路径] CD[..] .. 表示当前目录改变成父目录. 键入 CD [驱动器:], 可显示指定驱动器的当前目录. 键入不带参数的 CD 可显示当前驱动器和当前目录. 命令:CLS 功能:清除屏幕。 CLS 命令:COPY 功能:文件拷贝. COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination

[/A | /B]] [/V] [/Y | /-Y] source 指定被拷贝的文件. /A 表示 ASCII 正文文件. /B 表示二进制文件. destination 指定新文件的目录和文件名. /V 校验新文件是否正确. /Y 在重写原有的目标文件之前, 不让你确认. /-Y 在重写原有的目标文件之前, 让你确认. 开关项 /Y 可由环境变量 COPYCMD 预设. -Y 可以更改预设值.要合并多个文件时, 可指定单个目标文件, 但指定多个 源文件(使用通配符或文件1+文件2+文件3 格式). 命令:DATE 功能:显示或设置日期。 DATE [日期] 显示当前日期设置和输入新日期的提示,请键入 不带参数的 DATE。要保留现有日期,请按 ENTER。 命令:DEL/ERASE 功能:删除文件. DEL [驱动器:][路径]文件名 [/P] ERASE [驱动器:][路径]文件名 [/P] [驱动器:][路径]文件名指定被删除的文件, 用通配符指定多个文件. /P 删除每个文件之前显示确认信息. 命令:DIR 功能:显示目录中的文件和子目录列表。

windows批处理命令详解及脚本实例

批处理文件是将一系列命令按一定的顺序集合为一个可执行的文本文件,其扩展名为BAT。第一部分:批处理内部命令 1、REM REM 是个注释命令一般是用来给程序加上注解的,该命令后的内容在程序执行的时候将不会被显示和执行。例: REM 你现在看到的就是注解,这一句将不会被执行。在以后的例子中解释的内容都REM 会放在REM后面。请大家注意。 2、ECHO ECHO 是一个回显命令主要参数有OFF和ON,一般用ECHO message来显示一个特定的消息。例: Echo off Rem 以上代表关闭回显即不显示所执行的命令 Echo 这个就是消息。 Rem 以上代表显示"这就是消息"这列字符 执行结果: C:\>ECHO.BAT 这个就是消息。 3、GOTO GOTO 即为跳转的意思。在批处理中允许以":XXX"来构建一个标号然后用GOTO :标号直接来执行标号后的命令。例 :LABEL REM 上面就是名为LABEL的标号。 DIR C:\ DIR D:\ GOTO LABEL REM 以上程序跳转标号LABEL处继续执行。 4、CALL CALL 命令可以在批处理执行过程中调用另一个批处理,当另一个批处理执行完后再继续

执行原来的批处理。例: 批处理2.BAT内容如下: ECHO 这就是2的内容 批处理1.BAT内容如下: ECHO 这是1的内容 CALL 2.BAT ECHO 1和2的内容全部显示完成 执行结果如下: C:\>1.BAT 这是1的内容 这就是2的内容 1和2的内容全部显示完成 5、PAUSE PAUSE 停止系统命令的执行并显示下面的内容。例: C:\> PAUSE 请按任意键继续. . . 6、IF IF 条件判断语句,语法格式如下: IF [NOT] ERRORLEVEL number command IF [NOT] string1==string2 command IF [NOT] EXIST filename command 说明: [NOT] 将返回的结果取反值即"如果没有"的意思。 ERRORLEVEL 是命令执行完成后返回的退出值 Number 退出值的数字取值范围0~255。判断时值的排列顺序应该又大到小。返回的值大于或等于指定的值时条件成立。 string1==string2 string1和string2都为字符的数据,英文字符的大小写将看做不同,这个条件中的等于号必须是2个(绝对相等),条件想等后即执行后面的command EXIST filename 为文件或目录存在的意思。 IF ERRORLEVEL这条语句必须放在某一个命令后面。执行命令后由IF ERRORLEVEL来

批处理命令For循环命令详解

分类:2010-06-11 13:0416793人阅读(0) 批处理for命令详解 FOR这条命令基本上都被用来处理文本,但还有其他一些好用的功能! 看看他的基本格式(这里我引用的是批处理中的格式,直接在命令行只需要一个%号) FOR 参数%%变量名IN (相关文件或命令) DO 执行的命令 参数:FOR有4个参数/d /l /r /f 他们的作用我在下面用例子解释 %%变量名:这个变量名可以是小写a-z或者大写A-Z,他们区分大小写,FOR会把每个读取到的值给他; IN:命令的格式,照写就是了; (相关文件或命令) :FOR要把什么东西读取然后赋值给变量,看下面的例子 do:命令的格式,照写就是了! 执行的命令:对每个变量的值要执行什么操作就写在这. 可以在CMD输入for /看系统提供的帮助!对照一下 FOR %%variable IN (set) DO command [command-parameters] %%variable 指定一个单一字母可替换的参数。 (set) 指定一个或一组文件。可以使用通配符。 command 指定对每个文件执行的命令。 command-parameters 为特定命令指定参数或命令行开关。 现在开始讲每个参数的意思 /d 仅为目录 如果Set (也就是我上面写的"相关文件或命令") 包含通配符(* 和),将对与Set 相匹配的每个目 录(而不是指定目录中的文件组)执行指定的Command。 系统帮助的格式:FOR /D %%variable IN (set) DO command 他主要用于目录搜索,不会搜索文件,看这样的例子 @echo off for /d %%i in (*) do @echo %%i pause 把他保存放在C盘根目录执行,就会把C盘目录下的全部目录名字打印出来,而文件名字一个也不显示!

BAT(批处理)文件编写详细手册

BAT(批处理)文件编写详细手册 一、批处理文件简介 首先,批处理文件是一个文本文件,这个文件的每一行都是一条DOS命令(大部分时候就好象我们在DOS提示符下执行的命令行一样),你可以使用DOS下的Edit或者Windows的记事本(notepad)等任何文本文件编辑工具创建和修改批处理文件。 其次,批处理文件是一种简单的程序,可以通过条件语句(if)和流程控制语句(goto)来控制命令运行的流程,在批处理中也可以使用循环语句 (for)来循环执行一条命令。当然,批处理文件的编程能力与C语言等编程语句比起来是十分有限的,也是十分不规范的。批处理的程序语句就是一条条的 DOS命令(包括内部命令和外部命令),而批处理的能力主要取决于你所使用的命令。 第三,每个编写好的批处理文件都相当于一个DOS的外部命令,你可以把它所在的目录放到你的DOS搜索路径(path)中来使得它可以在任意位置运行。一个良好的习惯是在硬盘上建立一个bat或者batch 目录(例如C:/BATCH),然后将所有你编写的批处理文件放到该目录中,这样只要在path中设置上c:/batch,你就可以在任意位置运行所有你编写的批处理程序。 简单的说,批处理的作用就是自动的连续执行多条命令。 二、批处理中常用命令: 1.echo命令:表示显示此命令后的字符。字符不需要使用引号。其中,%和^两个字 符不能显示。 2.Echo off命令:表示在此语句后所有运行的命令都不显示命令行本身。即关闭echo 回显功能。可以使用echo on打开。 3.@命令:它是加在每个命令行的最前面,表示运行时不显示这一行的命令行(只能 影响当前行)。 4.call命令:调用另一个批处理文件(如果不用call而直接调用别的批处理文件, 那么执行完那个批处理文件后将无法返回当前文件并执行当前文件的后续命令)。 5.pause命令:运行此句会暂停批处理的执行并在屏幕上显示Press any key to continue...的提示,等待用户按任意键后继续。如果不想显示以上英文提示信息, 可以这样写:pause>null 6.rem命令:表示此命令后的字符为解释行(注释),不执行,只是给自己今后参考 用的(相当于程序中的注释)。 7.::命令:与rem命令等效。 例1:用edit编辑a.bat文件,输入下列内容后存盘为c:/a.bat,执行该批处理 文件后可实现:将根目录中所有文件写入 a.txt中,启动UCDOS,进入WPS等功能。 批处理文件的内容为: 命令注释: @echo off //不显示后续命令行及当前命令行

批处理命令详解

批处理命令详解

————————————————————————————————作者:————————————————————————————————日期:

批处理命令详解 1.Echo 命令 打开回显或关闭请求回显功能,或显示消息。如果没有任何参数,echo命令将显示当前回显设置。 语法?echo [{on|off}] [message] Sample:echo off / echo hello world?在实际应用中我们会把这条命令和重定向符号(也称为管道符号,一般用> >> ^)结合来实现输入一些命令到特定格式的文件中.这将在以后的例子中体现出来。??2.@命令 表示不显示@后面的命令,在入侵过程中(例如使用批处理来格式化敌人的硬盘)自然不能让对方看到你使用的命令啦。 Sample:@echo off?@echo Now initializing the program,please wait a minite... @format X: /q/u/autoset (format 这个命令是不可以使用/y这个参数的,可喜的是微软留了个autoset这个参数给我们,效果和/y是一样的。) ?3.Goto 命令?指定跳转到标签,找到标签后,程序将处理从下一行开始的命令。?语法:goto label (label是参数,指定所要转向的批处理程序中的行。)?Sample:?if {%1}=={} goto noparms if {%2}=={} gotonoparms(如果这里的if、%1、%2你不明白的话,先跳过去,后面会有详细的解释。) @Rem check parameters if null show usage?:noparms?echo Usage: monitor.bat Ser verIP PortNumber gotoend?标签的名字可以随便起,但是最好是有意义的字母啦,字母前加个:用来表示这个字母是标签,goto命令就是根据这个:来寻找下一步跳到到那里。最好有一些说明这样你别人看起来才会理解你的意图啊。 ?4.Rem 命令 注释命令,在C语言中相当与/*--------*/,它并不会被执行,只是起一个注释的作用,便于别人阅读和你自己日后修改。 Rem Message Sample:@Rem Here isthe description. 5.Pause 命令?运行 Pause命令时,将显示下面的消息: ?Press any key to continue . . .

批处理参数详解

如果没有一定的相关知识恐怕不容易看懂和理解批处理文件,也就更谈不上自己动手编写了 批处理文件是无格式的文本文件,它包含一条或多条命令。它的文件扩展名为 .bat 或 .cmd。在命令提示下键入批处理文件的名称,或者双击该批处理文件,系统就会调用Cmd.exe按照该文件中各个命令出现的顺序来逐个运行它们。使用批处理文件(也被称为批处理程序或脚本),可以简化日常或重复性任务。当然我们的这个版本的主要内容是介绍批处理在入侵中一些实际运用,例如我们后面要提到的用批处理文件来给系统打补丁、批量植入后门程序等。下面就开始我们批处理学习之旅吧。 一.简单批处理内部命令简介 1.Echo 命令 打开回显或关闭请求回显功能,或显示消息。如果没有任何参数,echo 命令将显示当前回显设置。 语法 echo [{ on|off }] [message] Sample:@echo off / echo hello world 在实际应用中我们会把这条命令和重定向符号(也称为管道符号,一般用> >> ^)结合来实现输入一些命令到特定格式的文件中.这将在以后的例子中体现出来。 2.@ 命令 表示不显示@后面的命令,在入侵过程中(例如使用批处理来格式化敌人的硬盘)自然不能让对方看到你使用的命令啦。 Sample:@echo off @echo Now initializing the program,please wait a minite... @format X: /q/u/autoset (format 这个命令是不可以使用/y这个参数的,可喜的是微软留了个autoset这个参数给我们,效果和/y是一样的。) 3.Goto 命令 指定跳转到标签,找到标签后,程序将处理从下一行开始的命令。 语法:goto label (label是参数,指定所要转向的批处理程序中的行。) Sample: if { %1 }=={ } goto noparms if { %2 }=={ } goto noparms(如果这里的if、%1、%2你不明白的话,先跳过去,后面会有详细的解释。)@Rem check parameters if null show usage :noparms echo Usage: monitor.bat ServerIP PortNumber goto end 标签的名字可以随便起,但是最好是有意义的字母啦,字母前加个:用来表示这个字母是标签,goto命令就是根据这个:来寻找下一步跳到到那里。最好有一些说明这样你别人看起来才会理解你的意图啊。 4.Rem 命令 注释命令,在C语言中相当与/*--------*/,它并不会被执行,只是起一个注释的作用,便于别人阅读和你自己日后修改。 Rem Message Sample:@Rem Here is the description.

批处理常用命令及用法大全_-__打印

注:如果对某一命令还不是很熟悉,可以在命令行窗口下输入:命令名/?的方式来获得帮助。 1 echo 和 @回显控制命令 @ #关闭单行回显 echo off #从下一行开始关闭回显 @echo off #从本行开始关闭回显。一般批处理第一行都是这个 echo on #从下一行开始打开回显 echo #显示当前是 echo off 状态还是 echo on 状态echo. #输出一个"回车换行",一般就是指空白行 echo hello world #输出hello world "关闭回显"是指运行批处理文件时,不显示文件里的每条命令,只显示运行结果批处理开始和结束时,系统都会自动打开回显 2 errorlevel程序返回码 echo %errorlevel%每个命令运行结束,可以用这个命令行格式查看返回码用于判断刚才的命令是否执行成功默认值为0,一般命令执行出错会设 errorlevel 为1 3 dir显示目录中的文件和子目录列表 dir #显示当前目录中的文件和子目录 dir /a #显示当前目录中的文件和子目录,包括隐藏文件和系统文件 dir c: /a:d #显示 C 盘当前目录中的目录 dir c:\ /a:-d #显示 C 盘根目录中的文件 dir d:\mp3 /b/p #逐屏显示 d:\mp3 目录里的文件,只显示文件名,不显示时间和大小 dir *.exe /s显示当前目录和子目录里所有的.exe文件其中 * 是通配符,代表所有的文件名,还一个通配符 ? 代表一个任意字母或汉字如 c*.* 代表以 c 开头的所有文件?.exe 代表所有文件名是一个字母的.exe文件如果指定的目录或文件不存在,将返回 errorlevel 为1;每个文件夹的 dir 输出都会有2个子目录 . 和 ... 代表当前目录.. 代表当前目录的上级目录 dir . #显示当前目录中的文件和子目录 dir .. #显示当前目录的上级目录中的文件和子目录 其它参数可参考 dir /? 4 cd更改当前目录 cd mp3 #进入当前目录中的mp3 目录 cd .. #进入当前目录中的上级目录 cd\ #进入根目录 cd #显示当前目录 cd /d d:\mp3 #可以同时更改盘符和目录 cd "Documents and Settings"\All users文件名带空格,路径前需要加上引号!!如果更改到的目录不存在,则出错返回 errorlevel=1 5 md创建目录 md abc #在当前目录里建立子目录 abc md d:\a\b\c #如果 d:\a 不存在,将会自动创建 6 rd删除目录 rd abc #删除当前目录里的 abc 子目录,要求为空目录 rd /s/q d:\temp #删除 d:\temp 文件夹及其子文件夹和文件,不需要按 Y 确认 7 del删除文件 del d:\test.txt #删除指定文件,不能是隐藏、系统、只读文件 del *.*删除当前目录里的所有文件,不包括隐藏、系统、只读文件,要求按 Y 确认 del /q/a/f d:\temp\*.*删除 d:\temp 文件夹里面的所有文件,包括隐藏、只读、系统文件,不包括子目录 del /q/a/f/s d:\temp\*.*删除 d:\temp 及子文件夹里面的所有文件,包括隐藏、只读、系统文件,不包括子目录 8 ren文件重命名 ren 1.txt 2.bak #把 1.txt 更名为 2.bak ren *.txt *.ini #把当前目录里所有.txt文件改成.ini文件 ren d:\temp tmp #支持对文件夹的重命名 9 cls清屏 10 type显示文件内容 type c:\boot.ini #显示指定文件的内容,程序文件一般会显示乱码 type *.txt #显示当前目录里所有.txt文件的内容 11 copy拷贝文件 XCOPY复制组文件 COPY复制文件 拷贝目录和文件——xcopy 在拷贝单个文件时,可以使用copy命令完成,但当我们要成批拷贝文件,甚至连同子目录一起拷贝时,就要用到xcopy。 copy c:\test.txt d:\复制 c:\test.txt 文件到 d:\ copy c:\test.txt d:\test.bak复制 c:\test.txt 文件到 d:\ ,并重命名为 test.bak copy c:\*.*复制 c:\ 所有文件到当前目录,不包括隐藏文件和系统文件不指定目标路径,则默认目标路径为当前目录 copy con test.txt从屏幕上等待输入,按 Ctrl+Z 结束输入,输入内容存为test.txt文件con代表屏幕,prn 代表打印机,nul代表空设备 copy 1.txt + 2.txt 3.txt合并 1.txt 和 2.txt 的内容,保存为 3.txt 文件如果不指定 3.txt ,则保存到 1.txt 1

批处理for命令的用法

对所有的批处理初学者来说,for的应用是最难理解以及掌握的。本文由浅入深,为大家专门讲解for的用法,希望大家喜欢。 首先应该明确的是,for不是一个简单的命令,它的用法比较复杂,它还可以带四个参数(/L /D /R /F),其中:/L和/F参数是最经常用到的。当然,它本身也可以不带参数,下面我们通过具体的例子来讲解for的运用。 一、不带参数的for: @echo off for %%i in (1 2 3 4 5) do echo %%i pause 将以上代码保存为批处理文件(如何保存?),然后运行,可以发现屏幕上显示1 2 3 4 5(每字一行) 是不是明白了一些?它的整个运行机制我们可以这样看:for不停的从括号中拿出5个“东西”来(以空格做间隔),并将这5个“东西”依次传给临时变量%%i,同时把这个变量echo出来.... 从这个例子我们可以看出,for的基本用法是: for 变量in (目标) do 干什么? 变量常用%%i 来表示,当然也可以换成%%j;目标就是待处理的对象集合,比如这里的1 2 3 4 5;这里的干什么的内容为:批处理命令。 【相关习题:】将你的名字用for命令分三行显示出来!!! 二、带参数/L 的for (这里的参数/L 可以理解为"list" 的意思,代表一个数列) 先看测试代码:复制内容到剪贴板 代码: @echo off

for /l %%i in (1 1 5) do echo %%i pause 显示结果也为:1 2 3 4 5(每字一行) 它的意思和上面的意思差不多,但是括号中的对象却不需要写成1 2 3 4 5 的形式了,而是:1 1 5,因为它启用了参数/L ,就是告诉for,这个括号里的对象是个数列,怎样的数列?就是以1 开始,步长为1 ,结束值为5的一个等差数列,再举个实例:复制内容到剪贴板 代码: ::显示从10 - 20 的所有偶数: @echo off for /l %%i in (10 2 20) do echo %%i pause 【相关习题:】显示1~20 间能被5整除的整数 三、带参数/f 的for(这里的参数/F可以理解为“file”的意思,代码处理对象为文本串) 参考教程:for 命令/f 参数通俗讲解 四、for的/D 和/R 参数(这两个参数个人比较少用) 1>/D参数(常用来查询当前目录或者指定目录的文件夹) 基本用法:FOR /D %variable IN (set) DO command [command-parameters] 如:查询F盘根目录下的文件夹复制内容到剪贴板 代码: @echo off for /d %%i in (f:\*) do echo %%i pause>nul 如果省略括号中的"f:\",则会直接查询批处理所在目录的文件夹

相关主题
文本预览
相关文档 最新文档