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-07-29 10:02
中国DOS联盟论坛 » 论坛回收站 » Please provide the specific program code or relevant content that needs to be modified so that I can assist you in modifying it. View 1,925 Replies 5
Original Poster Posted 2007-11-14 12:01 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 210
Posts 79
Joined 2007-04-14 10:49
19-year member
UID 85130
Gender Male
From 湖北
Status Offline
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 ]
Floor 2 Posted 2007-11-14 13:09 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
It should not delete all files. Did you make a mistake?
Floor 3 Posted 2007-11-14 13:26 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 210
Posts 79
Joined 2007-04-14 10:49
19-year member
UID 85130
Gender Male
From 湖北
Status Offline
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 ]
Floor 4 Posted 2007-11-14 13:52 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
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 ....
Floor 5 Posted 2007-11-14 18:44 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 210
Posts 79
Joined 2007-04-14 10:49
19-year member
UID 85130
Gender Male
From 湖北
Status Offline
Thanks, really, all the files in the root directory. Learned it
Floor 6 Posted 2010-05-23 13:13 ·  中国 山东 烟台 联通
中级用户
★★
Credits 231
Posts 110
Joined 2008-03-24 16:22
18-year member
UID 113876
Gender Male
From 中国大陆
Status Offline
That's not written like this呀》》》》》》》》》》》》》》》》》》.
Forum Jump: