Using WMI to list all subfolders of a folder
Hey,
I am trying to use WMI to list all the folders inside a folder remotely on a machien on our network here. I have some code but it uses the FileSystemObject and it dosen't work remotely.
Anyone know how I can procede to fix this problem and move on to some more code?
Here is the code that uses the File System Object.
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\FSO")
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
Wscript.Echo objSubfolder.Name, objSubfolder.Size
Next
Re: Using WMI to list all subfolders of a folder
I dont believe that FSO can get remote information.
This is some VB6 code I have that can get remote information. Its not the file system but may help you on your way. ;)
VB Code:
Private Sub Command1_Click()
'Add a reference to WMI
Dim System As Object
Set System = GetObject("winmgmts:{impersonationLevel=impersonate}!//MyOtherSystem/root/cimv2:Win32_ComputerSystem=""MyOtherSystem""")
MsgBox System.Caption
MsgBox System.PrimaryOwnerName
MsgBox System.Domain
MsgBox System.SystemType
End Sub
Re: Using WMI to list all subfolders of a folder
Try these classes of WMI for getting filesystem info. Also, I added one for Ping since I saw your other thread. ;)
Win32_PingStatus
CIM_DirectorySpecificationFile
CIM_ToDirectorySpecification
Re: Using WMI to list all subfolders of a folder
I'll look into those classes and see if they can get me the information I need. I'll update this thread when I know more information.
Thanks Robo ;)