China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-09 02:23
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » A question from an old post View 726 Replies 9
Original Poster Posted 2008-07-01 22:03 ·  中国 湖北 黄石 大冶市 电信
初级用户
Credits 110
Posts 45
Joined 2008-01-25 23:59
18-year member
UID 109558
Gender Male
Status Offline
Automatically delete all autorun.inf files with any attributes from any directory on all drives:
@ECHO off
FOR %%c in (Z,Y,X,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) do (
IF exist %%c: (
del /f /s /a /q %%c:autorun.inf
)
)


The second line checks whether drive %%c exists. My question is: can DOS recognize that (Z,Y,X,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) represent drive letters?
A newbie's confusion
Floor 2 Posted 2008-07-01 22:13 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Delete @ECHO off
Run this batch file in the command interpreter and you'll know
Floor 3 Posted 2008-07-01 22:47 ·  中国 湖北 黄石 大冶市 电信
初级用户
Credits 110
Posts 45
Joined 2008-01-25 23:59
18-year member
UID 109558
Gender Male
Status Offline
Haha, HAT again. I tried it in CMD and it showed: %%c was unexpected at this time
Does HAT mean that if it errors after running, there will be an error message, right?
Floor 4 Posted 2008-07-01 22:48 ·  中国 湖北 黄石 大冶市 电信
初级用户
Credits 110
Posts 45
Joined 2008-01-25 23:59
18-year member
UID 109558
Gender Male
Status Offline
So this post originally came from here
Floor 5 Posted 2008-07-01 22:53 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Change %%c to %c, then run it in the interpreter
Floor 6 Posted 2008-07-01 23:05 ·  中国 湖北 黄石 大冶市 电信
初级用户
Credits 110
Posts 45
Joined 2008-01-25 23:59
18-year member
UID 109558
Gender Male
Status Offline
In a FOR loop, isn't the control variable written with %%?
Do you mean changing the IF line?
Floor 7 Posted 2008-07-01 23:13 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
In a batch file the control variable is %%c
If you run it directly in the command interpreter, the control variable is %c
Floor 8 Posted 2008-07-01 23:14 ·  中国 湖北 黄石 大冶市 电信
初级用户
Credits 110
Posts 45
Joined 2008-01-25 23:59
18-year member
UID 109558
Gender Male
Status Offline
Thanks, HAT. HAT is really too good. If I have questions later I'll have to trouble you more, and ask for more guidance
Floor 9 Posted 2008-07-01 23:18 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Just because I have free time and practiced hands, that's all.
I really can't be called “too good”; the experts will laugh at me.
Let's all learn from each other.
Floor 10 Posted 2008-07-01 23:19 ·  中国 湖北 黄石 大冶市 电信
初级用户
Credits 110
Posts 45
Joined 2008-01-25 23:59
18-year member
UID 109558
Gender Male
Status Offline
I just looked at the usage of FOR again, and now I understand that %% is used in batch files. Haha, I learned a little more. Many thanks to HAT, thanks
Forum Jump: