"VB Script to search for a file name using Wildcards"

We are trying to create a VB Script that will search on a local drive for a file name that includes HELPinstructions

The file name has random numbers before it and sometimes it may have different extensions (EG 13HELPinstructions.html

I want to be able to run a wildcard search that will return a result if it finds anything or not.

We have a similar script that is working that searches for a file name that is always the same:

'Adaptation of CryptoWall Script

'Detect Cryptowall 4.0
'Run Script, It will either return a "System Clear" or a location path - "is Infected" message.

strComputer = "."
set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")

'Check for "helpyourfiles.html"


For each objShare in colShares 
    strInfected = False  
    If objFSO.fileexists(objShare.path & "\help_your_files.png") OR objFSO.fileexists(objShare.path & "\help_your_files.html") OR objFSO.fileexists(objShare.path & "\help_your_files.txt") OR objFSO.fileexists(objShare.path & "\help_your_files.txt")  OR objFSO.fileexists(objShare.path & "\help_your_files.html")  OR objFSO.fileexists(objShare.path & "\help_your_files.png") then 
        strInfected = True 
        wscript.echo "Network Share " & objShare.Path & " is INFECTED!" 
    End If 

'If no infection Quit with Success

If strInfected = False Then 
    wscript.echo "System Clear!" 
End If 

If anyone can modify this please so that it searches for the wildcard file name mentioned above that would be a great help!


created 1 month ago
Press Start
 1 1 1
You must be signed in before you can post a fix
Scripting Language: PowerShell

I don't know if VB script is a requirement or not but I have something in PowerShell that should do what you're looking for. It is simple enough to modify as well.

$FilesToSearch=Get-ChildItem C:\* -Recurse -ErrorAction SilentlyContinue | where {$_.Name -like "*3HELPinstructions*"}
#This can be easily modified to include different paths, network locations etc
#It can also be modified to run through a ForEach if there are multiple paths, network locations etc
#When testing this I had it run through my entire C drive in about 60 seconds

if ($FilesToSearch -ne $null) {Write-Host "Enter your found malicious files message here"}
  else {Write-Host "Enter your no malicious files message here"}

created 1 month ago
 70 1 9


Great glad to hear it's working for you. Would you mind choosing it as the fix so that other users can see that there is a fix for this? m.Polselli 1 month ago
Yup that worked, thanks a lot! :) Press Start 1 month ago

► Have questions?

► Something not working?

► Suggestions?

Post your questions on the meta site, where we discuss everything related to FixIT Scripts

visit meta now»