Results 1 to 4 of 4

Thread: Using WMI to list all subfolders of a folder

  1. #1

    Thread Starter
    Addicted Member Porsche944's Avatar
    Join Date
    Apr 2005
    Location
    Ann Arbor
    Posts
    182

    Question 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

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. Private Sub Command1_Click()
    2. 'Add a reference to WMI
    3.     Dim System As Object
    4.     Set System = GetObject("winmgmts:{impersonationLevel=impersonate}!//MyOtherSystem/root/cimv2:Win32_ComputerSystem=""MyOtherSystem""")
    5.    
    6.     MsgBox System.Caption
    7.     MsgBox System.PrimaryOwnerName
    8.     MsgBox System.Domain
    9.     MsgBox System.SystemType
    10.  
    11. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Addicted Member Porsche944's Avatar
    Join Date
    Apr 2005
    Location
    Ann Arbor
    Posts
    182

    Talking 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width