![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-09 01:23 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » A question from an old post |
| Printable Version 724 / 9 |
| Floor1 yiyuncao007 | Posted 2008-07-01 22:03 |
| 初级用户 Posts 45 Credits 110 | |
|
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 |
|
| Floor2 HAT | Posted 2008-07-01 22:13 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Delete @ECHO off
Run this batch file in the command interpreter and you'll know |
|
| Floor3 yiyuncao007 | Posted 2008-07-01 22:47 |
| 初级用户 Posts 45 Credits 110 | |
|
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? |
|
| Floor4 yiyuncao007 | Posted 2008-07-01 22:48 |
| 初级用户 Posts 45 Credits 110 | |
|
So this post originally came from here
|
|
| Floor5 HAT | Posted 2008-07-01 22:53 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Change %%c to %c, then run it in the interpreter
|
|
| Floor6 yiyuncao007 | Posted 2008-07-01 23:05 |
| 初级用户 Posts 45 Credits 110 | |
|
In a FOR loop, isn't the control variable written with %%?
Do you mean changing the IF line? |
|
| Floor7 HAT | Posted 2008-07-01 23:13 |
| 版主 Posts 5,017 Credits 9,023 | |
|
In a batch file the control variable is %%c
If you run it directly in the command interpreter, the control variable is %c |
|
| Floor8 yiyuncao007 | Posted 2008-07-01 23:14 |
| 初级用户 Posts 45 Credits 110 | |
|
Thanks, HAT. HAT is really too good. If I have questions later I'll have to trouble you more, and ask for more guidance
|
|
| Floor9 HAT | Posted 2008-07-01 23:18 |
| 版主 Posts 5,017 Credits 9,023 | |
|
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. |
|
| Floor10 yiyuncao007 | Posted 2008-07-01 23:19 |
| 初级用户 Posts 45 Credits 110 | |
|
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
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |