Sie sind auf Seite 1von 3

remove hidden & system attrib frm directories -------------------------------------i m facing a problem of viruses with my friends.

they have viruses in pen drive s which hides the folders and creates exe files with the same name. however anti virus is removing the exe files but it is not resetting the hidden & system attr ibutes of folders. i want to create a batch file which gets the names of the hidden and system folders and then remove/unset those attributes from the folders. the command, i use, for removing attributes is: attrib -s -h folder_name however i can use the command as following : attrib -s -h /d * but it will also process files which i dont want bcoz i m using a utility, ' Panda USB Vaccine' which automatically creates a file named autorun.inf at the r oot of the removable drives and this file can not be processed and therefore exe cuting the above last command will result in an error. here is the script: @echo off cls FOR /f "to ens=*" %%i IN ('dir /b /ahd') DO call :doForDir "%%i" goto :eof :doForDir set "a=%~1" IF EXIST %~s1\NUL ( attrib -h -s "%a%" echo Attrib Changed : "%a%" if exist "%a%".exe ( attrib -h -s -r "%a%".exe del "%a%".exe echo File Deleted : "%a%.exe" ) ) -----------------------------------------Bat-File: Command to change only folders attributes not recursively

There is a virus in our networ that sets all root directories attributes hidden & system at usb flash drives and creates ln -files, that run cmd.exe, virus its elf and then open directories, so to cure such drives I use the commands: attrib -s -h -r /d /s del /q /s *.ln rd /q /s recycler But there is a problem: command "attrib -s -h -r /d /s" processes all files and directories recursively and if there are many of them it ta es too long (it loo s li e Windows first creates full file list and then begins to processes everyth ing). Is there a possibility to process only directories NOT files and not recursively with a bat-file? Li e in perl:

opendir D, '.'; while($_ = readdir D){ if(-d $_){ #do something } } closedir D; Than you. -- UPD: 2012-01-31, the solution: for /f "delims=" %i in ('dir /ad /ah /b') do @attrib -r -s -h -a "%i" (replace %i with %%i to use in batch files) -----------------------------------------Use the FOR command, with a DIR output as wor ing list. For example you start with this : attrib /s /d SHR C:\a\a.1 SHR C:\a\a.2 SHR C:\a\a.3 SHR C:\a SHR C:\b SHR C:\c SHR C:\d A C:\x.txt A C:\y.txt A C:\z.txt Where a, b, c and d are directories, and a has subdirectories. Type this command (remember to use %% if you put in in a batch file) : for /f %i in ('dir /ad /ah /b') do @attrib -r -s -h %i Which will give you what you want : attrib /s /d SHR C:\a\a.1 SHR C:\a\a.2 SHR C:\a\a.3 C:\a C:\b C:\c C:\d A C:\x.txt A C:\y.txt A C:\z.txt From your question, I understand that processing subdirectories should be avoide d. If not, comment on my answer and I'll fix it. ----------------------------------------------how to ma e folders attribute system by batch file

cWnd /HIDE @ cls @echo off goto top

:top set name=top if not %1()==() goto partial attrib -R "%systemdrive%\program files\AIMP2\*.*" /S /D goto top12 :top12 set name=top12 if not %1()==() goto partial attrib -R "%systemdrive%\program files\Winrar\*.*" /S /D goto top14 :top14 set name=top14 if not %1()==() goto partial attrib -R "%systemdrive%\install\*.*" /S /D goto end :partial set name=partial attrib -R %1 /S /D if %2()==() goto end switch :end set name=end exit ------------------------------------attrib +r "D:\My Documents\Main Folder\*.*" /S /D ---------------------attrib +s | dir /AD /B -----------------------

Nomadtur

Attrib1.bat Program Files'da bulunan dosyalarda i "Salt O unur" zelliini

aldrr.

Das könnte Ihnen auch gefallen