remove hidden & system attrib frm directories

August 7, 2010 at 07:22:43
Specs: Windows XP
i m facing a problem of viruses with my friends. they have viruses in pen drives which hides the folders and creates exe files with the same name. however antivirus is removing the exe files but it is not resetting the hidden & system attributes 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 root of the removable drives and this file can not be processed and therefore executing the above last command will result in an error.

See More: remove hidden & system attrib frm directories

Report •

August 8, 2010 at 21:27:59
You can try the following

1.Go to command prompt and type that drive name assigning for removable device. for example (pendrive in G:)

2. Type attrib *.*,now it shows the hidden attrib files.

3. For example Auto run.inf is present.Type attrib autorun.inf -s -h -r -a

4. Now the Autorun.inf is free from hidden,then simply type del autorun.inf.

5. Now it removes from your Removable device,Likewise the hidden files are unhide to remove easily.

I hope it helps for U.............

Report •

August 9, 2010 at 04:56:43
the autorun.inf file, created by 'Panda USB Vaccine', is for safety. i dont want to remove and if i want to remove it, it cant do it bcoz they make this file delete proof, it can only be removed by formatting the drive.

dir /b /ahd > folders.txt
by using the above command, i can get a list of hidden folders in the file 'folders.txt'. now after that, what to do to get the folders' names one by one from the file and execute the attrib command on them?

Report •

August 9, 2010 at 08:21:32
i found the solution by searching and merging multiple post on this and other sites.

here is the script:

@echo off
FOR /f "tokens=*" %%i IN ('dir /b /ahd') DO call :doForDir "%%i"
goto :eof

set "a=%~1"
	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" ) )

Report •

Related Solutions

Ask Question