PGSystemTester

Flood Hard Drive Macro

Jan 28th, 2019 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Excel VBA macro intended to write garbage files to hard drive.
  2. 'Objective is to see how well this "cleans" a hard drive, meaning increases difficulty to recover deleted files.
  3. 'So far looks okay but use at your own risk (i.e. if you have serious data to wipe don't
  4.    'just trust some macro you found on Pastebin!
  5. 'Saving as txt files to reduce potential harm and not slow down virus scans
  6. '150 text files covers about 5 gigs.
  7.  
  8. 'updated Aug 2020 to use arrays. Improves speed by about 3x.
  9.  
  10. Sub WriteOverDeletedSpace()
  11. Const RoundsOfSaves As Long = 10
  12.  
  13.  
  14. Dim theClock As Double: theClock = Now
  15. Const PathFileText As String = "C:\Users\???????\Downloads\!Clutter\Junk\"
  16.  
  17. Dim wkbk As Workbook, r As Long, c As Long, z As Long
  18.  
  19. Application.ScreenUpdating = False
  20. Set wkbk = Workbooks.Add
  21.  
  22.     For z = 0 To RoundsOfSaves
  23.        
  24.         'Number of columns
  25.        c = 200
  26.         r = 49999
  27.            
  28.         ReDim theArray(1 To c, 1 To r) As Double
  29.             For x = 1 To c
  30.                 For y = 1 To r
  31.                     theArray(x, y) = VBA.Rnd * 65535
  32.                 Next y
  33.             Next x
  34.  
  35.  
  36.  
  37.         wkbk.Sheets(1).Range("A1").Resize(r, c) = theArray
  38.  
  39.         wkbk.SaveAs Filename:=PathFileText & Round(Evaluate("=value(NOW())") * 1000000000, 0), FileFormat:=xlCurrentPlatformText
  40.            wkbk.Sheets(1).UsedRange.ClearContents
  41.    
  42.     Next z
  43.  
  44. wkbk.Close (False)
  45. Application.ScreenUpdating = True
  46.  
  47. MsgBox "done in " & Round((Now - theClock) * 24 * 3600, 0) & " seconds."
  48. End Sub
  49.  
Add Comment
Please, Sign In to add comment