Search for Files Using a Wildcard Query

Uses the Like keyword to search for all files on a computer that begin with the tilde (~).

VBScript Code


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile where FileName Like '%~%'")

For Each objFile in colFiles
    Wscript.Echo objFile.Name
Next