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-13 22:57
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Solved] Batch delete virus that deletes all specific files with the same name on the hard drive View 8,744 Replies 27
Original Poster Posted 2006-09-20 07:26 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
20-year member
UID 57801
Gender Male
Status Offline
Hello everyone!
My computer is XP, with disks C, D, E, F, G, H, etc. Now, because the computer was infected with a virus, I formatted the C drive and reinstalled the system, but there are _desktop.ini files (this is a virus) in various subdirectories and subfolders of other disks. The files themselves have the attributes "Hidden, Read-only, System", and they cannot be directly deleted. I can't delete them one by one in the command line mode, so I ask how to write a batch script to kill all this _desktop.ini on the hard drive. (What I am asking for here is the syntax of the batch script. The special virus-killing tool software is not in the discussion. Also, please don't delete the post, because I have searched relevant posts and can't completely solve this problem, so I posted a new post to ask for advice, please forgive me!)
@echo off
for %%i ('_desktop.ini') --------- do attrib -r -a -h -s _desktop.ini & del _desktop.ini
pause
exit

The idea is to first find all _desktop.ini files in the subdirectories of each partition on the hard drive, and after finding them, use ATTRIB to change their attributes, and then use DEL to delete this file, so that there will be no more of this virus on the hard drive. Please give me your advice---------Thank you!
It is worth noting that there must be Chinese paths or paths with spaces in the path. I am waiting for your advice---------
Also, I want to ask, if the system is WIN2000, will this batch script be applicable?


[ Last edited by flying008 on 2006-9-20 at 20:27 ]
Floor 2 Posted 2006-09-20 07:30 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
20-year member
UID 57801
Gender Male
Status Offline
Although the FIND search function under WINDWOS may be able to achieve similar functions, I am sincerely seeking the syntax of batch processing and learning, please give your advice without sparing------
Floor 3 Posted 2006-09-20 07:43 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The following code can delete _desktop.ini in all folders on the entire disk regardless of its attributes.

@echo off
setlocal enabledelayedexpansion
for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set var=%%i
set drive=!var:~-2!
fsutil fsinfo drivetype !drive!|find "Fixed">nul && del /a /f /s !drive!\_desktop.ini
)
pause
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 4 Posted 2006-09-20 08:05 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
The code of Namejm is too powerful. It's all fsutil fsinfo drivetype !drive!|find "Fixed", heh heh

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 5 Posted 2006-09-20 08:06 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Copying the code of some virus maker, heh heh.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 6 Posted 2006-09-20 08:09 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
Strong!!! First list all hard disk drive letters, then delete the specified file.

[ Last edited by pengfei on 2006-10-14 at 09:30 ]
业精于勤而荒于嬉,形成于思而毁于随。
Floor 7 Posted 2006-09-20 08:14 ·  中国 广东 广州 电信
中级用户
★★
Credits 259
Posts 112
Joined 2006-09-18 04:55
19-year member
UID 62928
Gender Male
Status Offline
Using this piece of code to mess with other files is not bad either! Hehe!
Floor 8 Posted 2006-09-20 08:29 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Tips: Personal experience suggests that: There are no pure file viruses. Generally, they still infect the registry

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 9 Posted 2006-09-20 09:50 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
The En virus won't be a virus if it doesn't infect the registry. The viruses of this type by the thread starter generally spread via CDs and USB drives, so it's quite important to disable autoplay in the group policy!
第一高手 第二高手

Floor 10 Posted 2006-09-20 20:20 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
20-year member
UID 57801
Gender Male
Status Offline
It has been solved!!!
1. First of all, I sincerely thank namejm here! It is your code and help that enabled me to successfully realize virus killing and learn grammar.
2. At the same time, I thank all the great people who read the post and gave advice and the members of the DOS Union!
3. To electronixtar: I have restored the system, so there is no such infection problem in the registry of the system disk. Thank you for your reminder.
 To fastslz: I have prohibited autorun in the group policy. Thank you! When I first came to the forum, there were your help as well as the help of electronixtar and BagPipe and other experts. Thank you all!
Floor 11 Posted 2006-09-22 00:53 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
wmic datafile where "filename='desktop' and Extension='ini'" call delete /NOINTERACTIVE
Floor 12 Posted 2006-09-22 00:58 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
Version 3742668, the moderator solved it with just one sentence, impressive. When can you explain the usage of wmic for us?

By the way, point out the moderator's oversight: the original poster needs to delete _desktop.ini, not desktop.ini, heh, a difference of one symbol.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 13 Posted 2006-09-22 01:35 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
The 3742668 moderator and brother namejm's code is too powerful, I can't understand it at all, heh heh~ Learning from you.

I'll just post a section of code that everyone can understand! It's also to force delete the _desktop.ini file throughout the disk:

@echo off
if exist "%tmp%\note.txt" del /a "%tmp%\note.txt" >nul 2>nul
set num=0
setlocal enabledelayedexpansion
for %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%i: (
cd\
for /f "tokens=*" %%a in ('dir /s /a-d /b %%i:\_desktop.ini') do (
echo %%a>>"%tmp%\note.txt"
set /a num=!num!+1
del /q /a /f "%%a"
)
)
)
cls
echo Total deleted files: %num%
pause
if not "%num%"=="0" start "" "%tmp%\note.txt"

[ Last edited by pengfei on 2006-9-23 at 08:27 ]
业精于勤而荒于嬉,形成于思而毁于随。
Floor 14 Posted 2006-09-22 05:10 ·  中国 广西 梧州 电信
初级用户
Credits 22
Posts 11
Joined 2006-05-11 11:29
20-year member
UID 55321
Status Offline
Why not del /s/a _desktop.ini under the drive letter? del /?
Floor 15 Posted 2006-09-22 07:31 ·  中国 甘肃 张掖 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
I haven't used wmic yet
Forum Jump: