OK, i am trying to get this piece to work, i am enumerating the file properties within a directory and all the child directories of that directory. I am having problems with this one piece. I have simplified my code down to work on this piece and I can't seem to get it to work properly. I will get the "Done" echo but not the rest and if i don't put it in the For Each statement it does give me an error about object does not support this property. When i google this it shows the exact syntax I am using. I am confused at this point.
Also one note, i did try the
method but that didn't work, it only works if i put the actual path in. I did try the objFile.Path as well and that didn't work either.
Code:
dim colFiles, strPath, fs, f, strString
dim objFile
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile Where name = 'c:\\<path>\\<filename>'")
For each objFile in colFiles
Wscript.Echo "File name: " & objFile.FileName
Wscript.Echo "File name: " & objFile.FileName
Wscript.Echo "Path: " & objFile.Path
Next
Wscript.Echo "Done"
Also one note, i did try the
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(objFile)
Wscript.Echo f.Path