Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Folder existence 1

Status
Not open for further replies.

glmrenard

Technical User
Oct 29, 2002
52
FR
Hello everybody,

I need to know if a remote folder exist but not with UNC notation but with WMI
Here my code :

I have a list of folder which represents my users and inside some of this folder I have the folder TOTO.
And I want to know the toto size (with a recursive function) but it crashes on this :
for each mbx in listeMbx
mbx=mbx+"\Archives"
wscript.echo mbx
redim listeArchives(0) : listeArchives(0)=mbx
build_mbxTree mbx,svc,listeArchives
next

sub build_mbxTree(sroot, wmisvc, listeArchives)
sQuery="Associators of {Win32_directory.name='" & sroot & "'} " & _
"where AssocClass=win32_subdirectory " & _
"ResultRole=PartComponent"
'wscript.echo sQuery
set cfolder=wmisvc.execquery(sQuery)
wscript.echo cfolder.count
'wscript.echo "total = " + cstr(cfolder.count)
for each ofolder in cfolder
wscript.echo ofolder.name
i=ubound(listeArchives)+1
redim preserve listeArchives(i)
listeArchives(i-1)=ofolder.name 'consistently in unescaped string format
wscript.echo i,ofolder.name
next
redim preserve listeArchives(i-1)
for each ofolder in cfolder
build_mbxtree ofolder.name, wmisvc, afolder
next
end sub

It crashes at :
wscript.echo cfolder.count
'wscript.echo "total = " + cstr(cfolder.count)
for each ofolder in cfolder


With

C:\exploit\scripts\dir3.vbs(45, 2) SWbemObjectSet: Not found

Thanks for your help...


 
build_mbxTree mbx,svc,listeArchives
Where and how is instantiated svc ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hello glmrenard,

I had answered your worry in another context in the previous thread. But, to isolate the problem to just verify the existence of a purported folder with certain path, you can do this.
Code:
sroot="d:\test\abc"
snode="a0b1c2"

squery="select name from cim_directory where name='" & _
    replace(sroot,"\","\\") & "'"
set cdir=getobject("winmgmts:\\"& snode & "\root\cimv2").execquery(squery)
if cdir.count=0 then
    wscript.echo "Directory "& sroot & " does not exist on" & snode & "."
else
    wscript.echo "Directory " sroot & " exists on " & snode & "."
end if
set cdir=nothing
(Using this under synchronous query only.)

regards - tsuji
 
typo: (second wscript.echo)
[tt]
wscript.echo "Directory " [red]&[/red] sroot & " exists on " & snode & "."
[/tt]
- tsuji
 
Thanks Tsuji,

It's really great to you for giving me so usefull answer !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top