0

I need to find out is the path to the folder includes hidden folders or not. Does anybody know how to do it? I have to use associators. Now my script only shows is the exact folder hidden or not and not checking the path to it.

Dim xdoc

Function CreateFolders(objFile)
    Dim elem
    Dim attr
    Set elem = xdoc.CreateElement("Folder")
    Set attr = xdoc.CreateAttribute("Description")
    attr.Value = objFile.Description
    elem.SetAttributeNode attr
    Set CreateFolders = elem
End Function

Dim FilePath
Dim objFile
Dim root
Dim elem, elem1
Dim FilePath2

Set oFSO = CreateObject("Scripting.FileSystemObject")

If WScript.Arguments.Count > 0 Then
    sFile = WScript.Arguments(0)

    If oFSO.FileExists(sFile) Then
        Set oFile = oFSO.GetFile(sFile)
        sModify = oFile.DateLastModified
    End If
End If
FilePath2 = WScript.Arguments(0)

Set xdoc = CreateObject("MSXML2.DOMDocument.6.0")
xdoc.AppendChild xdoc.CreateProcessingInstruction("xml", "version=""1.0"" encoding=""utf-8""")
FilePath = "C:\Users\User\Downloads\My123.xml"

Set root = xdoc.CreateElement("Folders")
xdoc.AppendChild root

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Directory WHERE Name = '" & FilePath2 & "'")

For Each objFile In colFiles
    Wscript.Echo objFile.Name & "  " & "Status: "  & objFile.Hidden
    Set elem = CreateFolders(objFile)
    root.AppendChild elem
Next

xdoc.Save FilePath
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Nick
  • 11
  • 3
  • Take a look at the description of the tag `vbscript` and reconsider using it. – Vityata Dec 18 '17 at 10:30
  • 1
    *I have to use associators.* Why? If this is a homework question: please show the actual task and what you already tried (there is no attempt to use associators in the code you posted). – Ansgar Wiechers Dec 18 '17 at 10:41
  • Yes. It's a homework. I don't know why should I use associators here and I was just told to do that. – Nick Dec 18 '17 at 15:47

0 Answers0