Hack Forums
[Shell] File to delete flash drive files - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Shell] File to delete flash drive files (/showthread.php?tid=5673776)



File to delete flash drive files - GG Luck GG - Jul 19, 2017

Is there any way to code a file that if it's ran it will delete all the files on the flash drive regardless of what computer it's plugged into?


* - Hackoo - Jul 19, 2017

(Jul 19, 2017 09:00 PM)GG Luck GG Wrote:  Is there any way to code a file that if it's ran it will delete all the files on the flash drive regardless of what computer it's plugged into?
Hi ✌
Why you need a such descrutive code like that ? what's your aim ?


* - Sphere of Madness - Jul 21, 2017

Code below scan all drives on PC and remove all files/folders (hidden and read-only incl.) only from removable drives.

Code
@echo off
for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (
   for %%c in (%%b) do (
      for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (
         if %%d equ Removable (
            cd /d %%c
            attrib -r -s -h /S /D
            for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
         )
      )
   )
)