Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

WMI File Size

Avatar of hoshie329
hoshie329Flag for Afghanistan asked on
VB Script
8 Comments1 Solution2872 ViewsLast Modified:
I am working on a script that utilizes WMI to get the size of a particular file.

  So far, it doesn't appear to be even looking in the directory -- I receive 0 files found

can any one tell why this isn't returning any file count.

after it gets the files I need it to look return the file size of the file I specify
Computer = "."
Drive = "c:"
Path = "\\Documents and Settings\\someone\\My Documents"
strFile = "test.txt" 
 'Normalize the Path variable for use in the query
if right(Path,1) <> "\" then
       Path = Path & "\"
End If
Path = replace(Path,"\","\\")

 'For testing:
'wscript.echo Computer & " " & Drive & " " & Path

 'Execute the WMI query to get the file information
Set WMIService = GetObject("winmgmts:\\" & Computer & "\root\cimv2")
WMIQuery = "Select FileSize from CIM_DataFile where drive = '" & Drive & "' and Path = '" & Path & "'"
Set Results = WMIService.ExecQuery(WMIQu<wbr ></wbr>ery)

 'For testing:
wscript.echo "Found " & Results.Count & " files"
Avatar of rscottvan
rscottvanFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers