WMI script terminate at longer *name*.

G

Guest

i wrote a WMI script which list all files in 1 folder in 1 computer. My
script will fail and stop if the folder's name has space or more than 8.3
length.

how do i correct this problem.?

thank you.
 
G

Guest

here is the code. If you run it, it will stop running when it encounters
longer name of a folder which has many spaces between words.

i hope you can fix this problem. Thanks

'============

strDir = “c:\windowsâ€
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Call EnumAll(strDir)

'====sub below=======
sub EnumAll(fldr)

Set FileList = objWMIService.ExecQuery("ASSOCIATORS OF
{Win32_Directory.Name='"&fldr&"'}" & " Where ResultClass = CIM_DataFile ")

For Each objFile In FileList

wscript.echo("File: "&objFile.Name)

Next

set Folders=objWMIService.ExecQuery("ASSOCIATORS of
{Win32_Directory.Name='"&fldr&"'}" & " where AssocClass = Win32_Subdirectory
ResultRole = PartComponent")

For each folder in Folders
wscript.echo(vbcrlf&"Folder: "&folder.Name)
Call EnumAll(folder.Name) 'recursion. Go through everything

next

end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top