Computing.Net > Forums > Programming > batch file to search all drives

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file to search all drives

Reply to Message Icon

Name: houdinihar
Date: January 6, 2009 at 10:14:36 Pacific
OS: Windows XP, sp2
CPU/Ram: 2.8 ghz intel, 500mb
Product: Unknown / DELL
Subcategory: Batch
Comment:

I want to create a batch file that needs to scan all my drives for "autorun.inf" remove all attributes then del these files because of a virus. here is what I have so far and it isn't refined.
//
@echo off
CLS
rem "code needed for fixed drive search. probably some kind of a nested loop to include below code when each fixed drive is found."
IF EXIST autorun.inf attrib -s -h -r autorun.inf /d
DEL autorun.inf
"repeat until all drives searched"
exit
///////////////

any help to complete would be greatly appreciated.
houdinihar



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: January 6, 2009 at 22:24:09 Pacific
Reply:

search all available drives include floppy & cdrom. sorry, no checking against those drive.


@echo off & setlocal enabledelayedexpansion

for /f "tokens=1,2 delims=\ " %%a in ('fsutil fsinfo drives^|more/e/t0') do (
if "%%b"=="" (set drive=%%a) else set drive=%%b
echo scanning !drive!
for /f "tokens=*" %%f in ('dir !drive!\autorun.inf /b /s 2^>nul') do attrib -a -s -h "%%f" & del "%%f" & echo %%f
)



0
Reply to Message Icon

Related Posts

See More


copy web text and replace... Batch file to extract cer...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file to search all drives

Batch to search all drives and copy newest www.computing.net/answers/programming/batch-to-search-all-drives-and-copy-newest/20316.html

search all drives for 'instances of www.computing.net/answers/programming/search-all-drives-for-instances-of/16458.html

Batch File To search file extension www.computing.net/answers/programming/batch-file-to-search-file-extension/18286.html