title: VB Script to delete certain files and if files are found copy other files to directory
body: <p>I have a hard drive that is infected with a virus. The virus encrypts files and then asks for a ransom to unencrypt them. The files are HELP_DECRYPT.HTML, HELP_DECRYPT.PNG, HELP_DECRYPT.TXT and HELP_DECRYPT.URL.</p>
  
  <p>There are thousands of infected files on the drive. I am trying to write a script to go through all the folders on the drive, and if it finds any of the malicious files it deletes them. I then want if to copy files from the backup drive in the same directory ie. if found in I\Folder\ if would get files from F\Folder\ .</p>
  
  <p>In my case the infected drive is Y, and the backup drive is X.</p>
  
  <p>I am relatively new to VBScripts and here is what I have so far:</p>
  
  <pre><code>    set fso = CreateObject("Scripting.FileSystemObject")
  ShowSubFolders FSO.GetFolder("Y:\"), 3
  
  Sub ShowSubFolders(Folder, Depth)
      If Depth &gt; 0 then
          For Each Subfolder in Folder.SubFolders
              'Wscript.Echo Subfolder.Path
      DeleteFiles(subFolder.path)
    On Error Resume Next
              ShowSubFolders Subfolder, Depth -1 
  
          Next
      End if
  End Sub
  
  
    'deletes the malicious files and calls the copy function'
  Function DeleteFiles(path)
  'wscript.echo("in delete method")
    set FSO2 = Createobject("Scripting.FileSystemObject")
    set ofolder = createobject("Scripting.FileSystemObject")
    set ofolder = FSO2.GetFolder(path)
  
    if FSO2.FileExists("HELP_DECRYPT.URL") Then
      ofolder.DeleteFile("HELP_DECRYPT.PNG")
      ofolder.DeleteFile("HELP_DECRYPT.HTML")
      ofolder.DeleteFile("HELP_DECRYPT.URL")
      ofolder.DeleteFile("HELP_DECRYPT.TXT")      
        wscript.echo("DeletedFiles")
    copyFiles(FSO.GetParentFolder) 
      end if
  
  End Function
  
  
    'copies files from the backup'
  Function CopyFiles(from)
      dim to1 'where we're copying to
      to1=from 'where we're copying from
      Call Replace (from, "Y:", "X:")
      SET FSO3 = CreateObject("Scripting.FileSystemObject")
      For Each file In from 'not sure about "file"
          FSO3 = file
          Call FSO3.CopyFile (from, to1, true)'copies file and overwrites if already there
      Next
  End Function
  </code></pre>