|
zqdarkday
中级用户
  
积分 210
发帖 79
注册 2007-4-14 来自 湖北
状态 离线
|
『楼 主』:
帮我修改一下程序
使用 LLM 解释/回答一下
我最近练习练习编写了一个杀U盘病毒的小程序,但是发现有个问题。
具体代码如下
@echo off
cls
cd\
color fc
echo 正在使用本程序,请稍等...
echo 为防止您的移动存储设备再次中招,所以在您的建了几个文件夹,不是病毒,请您放心!
set m=autorun.inf
for /f "skip=1 tokens=1,2* delims==" %%a in (autorun.inf) do (set n=%%b)
for /d %%c in (c d e f h i) do (if exist %%c:\%n% attrib -s -h %%c:\%n% && del /f %%c:\%n%)
for /d %%d in (c d e f h i) do (if exist %%d:\%m% attrib -s -h %%d:\%m% && del /f %%d:\%m%)
for /d %%e in (c d e f h i )do (md %%e:\autorun.inf & attrib +s +h %%e:\autorun.inf)
for /d %%f in (c d e f h i )do (md %%f:\autorun.ini & attrib +s +h %%f:\autorun.ini)
for /d %%g in (c d e f h i )do (md %%g:\autorun.exe & attrib +s +h %%g:\autorun.exe)
pause
当c d e f 等盘中如果没有autorun.inf 或它指定的.exe文件的话,del 就会删除c d e f中的所有文件,连 && 都没用了,请大家帮我修改下,其实我觉得这是个大问题耶!!!
Last edited by zqdarkday on 2007-11-14 at 12:22 PM ]
Recently I practiced writing a small program to kill USB flash drive viruses, but I found a problem.
The specific code is as follows
@echo off
cls
cd\
color fc
echo Is using this program, please wait...
echo To prevent your mobile storage device from being infected again, so I have created a few folders for you. They are not viruses, please rest assured!
set m=autorun.inf
for /f "skip=1 tokens=1,2* delims==" %%a in (autorun.inf) do (set n=%%b)
for /d %%c in (c d e f h i) do (if exist %%c:\%n% attrib -s -h %%c:\%n% && del /f %%c:\%n%)
for /d %%d in (c d e f h i) do (if exist %%d:\%m% attrib -s -h %%d:\%m% && del /f %%d:\%m%)
for /d %%e in (c d e f h i )do (md %%e:\autorun.inf & attrib +s +h %%e:\autorun.inf)
for /d %%f in (c d e f h i )do (md %%f:\autorun.ini & attrib +s +h %%f:\autorun.ini)
for /d %%g in (c d e f h i )do (md %%g:\autorun.exe & attrib +s +h %%g:\autorun.exe)
pause
If there is no autorun.inf or the specified.exe file in drives such as c d e f, del will delete all files in c d e f, and even && doesn't work. Everyone, please help me modify it. Actually, I think this is a big problem!!!
Last edited by zqdarkday on 2007-11-14 at 12:22 PM ]
|
|
2007-11-14 12:01 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
应该不会删除所有文件,你是不是搞错了?
It should not delete all files. Did you make a mistake?
|
|
2007-11-14 13:09 |
|
|
zqdarkday
中级用户
  
积分 210
发帖 79
注册 2007-4-14 来自 湖北
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
re lxmsn :我试过了是不会删除*.*
del /f %%c:\%m% 但%m%没有的时候你说会怎么样呢???
关于这点是什么意思啊?
但一个变量为空的时候,cmd还要提示是什么意思啊?
是不是所有的都是这样呢?
我现在还是不敢del /q 因为是我同学用的,怕把他们的东西搞没了, 希望高手解决下这个问题!!!
Last edited by zqdarkday on 2007-11-14 at 01:41 PM ]
re lxmsn: I tried it and it won't delete *.*
del /f %%c:\%m% but what happens when %m% doesn't exist?
What does this point to?
But when a variable is empty, why does cmd still prompt?
Is this the case for all?
I still don't dare to del /q because it's my classmate's, afraid of deleting their stuff, hope the expert solves this problem!!!
Last edited by zqdarkday on 2007-11-14 at 01:41 PM ]
|
|
2007-11-14 13:26 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
del /f %%c:\%n%
当n为空值的时候,会提示你删除%%c:\*,这只是%%c根目录里面的所有文件,不包括子目录。
可以弄个判断语句来判断%n%时候为空,在做下一步的处理。。
if not "%n%"=="" dosomething ....
del /f %%c:\%n%
When n is an empty value, it will prompt you to delete %%c:\*, which is only all the files in the root directory of %%c, not including subdirectories.
You can create a judgment statement to judge whether %n% is empty, and then do the next processing.
if not "%n%"=="" dosomething ....
|
|
2007-11-14 13:52 |
|
|
zqdarkday
中级用户
  
积分 210
发帖 79
注册 2007-4-14 来自 湖北
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
谢谢哦,真的是根目录里面的所有文件,学习了
Thanks, really, all the files in the root directory. Learned it
|
|
2007-11-14 18:44 |
|
|
sgzhou6688
中级用户
  
积分 231
发帖 110
注册 2008-3-24 来自 中国大陆
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
不是这样的写的呀》》》》》》》》》》》》》》》》》》。。
That's not written like this呀》》》》》》》》》》》》》》》》》》.
|
|
2010-5-23 13:13 |
|