title: how to extract the properties of all files and folders of a particular directory using vbscript?
body: <p>I have been able to extract information of of all files in a folder and also all subfolders of that particular folder, but when I want to extract information (i.e. file type,  file path, file size and file name) of all the files and folders of a particular DIRECTORY, I am not able to do it. It says PERMISSION DENIED.</p>
  
  <p>The script is as follows:</p>
  
  <pre><code>Option Explicit
  Dim objFSO,objf,objfolder, objFile, strFileProperties, strFiles,OBJFLD,objfile2
  dim objf1,objfile1,objtextfile,strfolderproperties,objsubfld,objfl,objfl1,strfileproperties2
  
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  
  Set objf= objFSO.Getfolder("C:\")
  set OBJFLD=objf.subfolders
  for each objfolder in OBJFLD
  
    strFolderproperties =_
      strFolderproperties &amp; "Number of files: " &amp; objFolder.Files.Count &amp; VbCrLf
  
    set objfile2=objfolder.files
    for each objfile in objfile2
  
      ' Display generel file properties of every subfld
      strFileProperties = strFileProperties &amp; "File name: " &amp; objFile.Name &amp; VbCrLf
      strFileProperties = strFileProperties &amp; "File path: " &amp; objFile.Path &amp; VbCrLf
      strFileProperties = strFileProperties &amp; "File size: " &amp; objFile.Size &amp; " bytes" &amp; VbCrLf
      strFileProperties = strFileProperties &amp; "File type: " &amp; objFile.Type &amp; VbCrLf &amp; vbcrlf
    next
  next
  
  Set objf= objFSO.Getfolder("C:\")
  set OBJfl=objf.files
  for each objfl1 in OBJfl
    'display properties of the files of the main folder   
    strFileProperties2 = strFileProperties2 &amp; "File name: " &amp; objfl1.Name &amp; VbCrLf
    strFileProperties2 = strFileProperties2 &amp; "File path: " &amp; objFl1.Path &amp; VbCrLf
    strFileProperties2 = strFileProperties2 &amp; "File size: " &amp; objFl1.Size &amp; " bytes" &amp; VbCrLf
    strFileProperties2 = strFileProperties2 &amp; "File type: " &amp; objFl1.Type &amp; VbCrLf &amp; vbcrlf
  next
  
  set objf1=objfso.getfolder("E:\logs3")
  
  set objfile1=objfso.getfile( "E:\logs3\database.txt")
  
  set objf1=nothing
  set objfile1=nothing
  
  set objtextfile=objfso.opentextfile("E:\logs3\database.txt",8,true)
  
  objtextfile.writeline(strfileproperties)
  objtextfile.writeline(strfileproperties2)
  objtextfile.close
  
  set objf1=objfso.getfolder("E:\logs3")
  
  set objfile1=objfso.getfile( "E:\logs3\database.txt")
  
  set objf1=nothing
  set objfile1=nothing
  
  set objsubfld=objfso.opentextfile("E:\logs3\database.txt",8,true)
  objsubfld.writeline(strfolderproperties)
  objsubfld.close
  </code></pre>
  
  <p>Note: This script works when I use it to extract info of files of any folder but the  whole directory!</p>
  
  <p>Any solutions? Is it possible to get info of all files and folders of the directory?</p>
  
  <p>Error message is as follows:</p>
  
  <pre><code>line:15
  character:12
  error:permission denied
  </code></pre>