I don't mind sitting and writing a LOOONG VBScript version of the process.
I prefer the short version which basically perform what you want.
If you insist doing it in vbscript, update this thread :)
Just a reminder, the below example reads a text file (computers.txt, line
by line) and pass it to WMIC.
WMIC, search for every file on C drive that have a name like *error.doc and
deletes it, in addition a log file is created
for each computer, the log contains the deleted files (path) in c:\logs (make
sure it exists).
for /f %%a in (computers.txt) do (
WMIC /node:%%a path cim_datafile WHERE Drive = 'c:' AND FileName LIKE
'%error' AND Extension ='doc'" delete > c:\logs\%%a.log
)
---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
> shay,
>
> finally i made one script and able to delete file using LIKE. But i
> need a few modification in this.i will store all computer names in a
> text file, so the script has to pick machines one by one. And i need
> seperate logs for all machines with details from where it has deleted
> all the files. can you please help me. here is my script.
>
> Dim strComputer, strExtension
>
> strComputer = "."
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
> "\root\cimv2")
>
> Set colFiles = objWMIService.ExecQuery _
> ("SELECT * FROM CIM_Datafile WHERE (Drive = 'c:' ) AND FileName
> LIKE '%error' AND Extension = 'doc" & strExtension & "'")
> For Each objFile in colFiles
> objFile.Delete
> Next
> thanks in advance
>
> binu
>
> http://forums.techarena.in
>
Bookmarks