1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| scomputer="."
set svc=GetObject("winmgmts:\\" & scomputer & "\root\cimv2")
'drive c:, d: etc... (no backslash)
'basedir start with backslash \test no trailing backslash
'filebasename xxx without extension
'fileextension no dot
drive="C:"
basedir="\users\Username\AppData\Local\Apps\2.0"
filebasename="Cgi.Telefi.Client"
fileextension="exe"
searchfile basedir
function searchfile(basedir)
dim dirname, path, squery_subdir, squery_file, cdirs, odir, cfiles, ofile
dirname=drive & replace(basedir,"\", "\\")
path=replace(basedir,"\","\\") & "\\"
squery_file="select * from CIM_DataFile where drive=""" & drive & """ and filename=""" & filebasename & """ and path=""" & path & """"
if len(trim(fileextension))<>0 then
squery_file=squery_file & " and extension=""" & trim(fileextension) & """"
end if
set cfiles=svc.execquery(squery_file)
if cfiles.count<>0 then 'corrigé
for each ofile in cfiles
wscript.echo "object found : " & ofile.caption
next
else
'wscript.echo "query : " & squery_file & vbcrlf & "return empty"
end if
squery_subdir="ASSOCIATORS of {Win32_Directory.Name=""" & dirname & """} where AssocClass=Win32_Subdirectory ResultRole = PartComponent"
set cdirs=svc.execquery(squery_subdir)
if cdirs.count<>0 then
for each odir in cdirs
searchfile odir.path & odir.filename
next
end if
end function |
Partager