VBS Script Help.

Posted by MalsiaPro on Stack Overflow See other posts from Stack Overflow or by MalsiaPro
Published on 2010-02-16T11:00:29Z Indexed on 2010/03/30 5:03 UTC
Read the original article Hit count: 379

Filed under:
|

I managed to get this code from you guys here, thanks so much with a collegue of mine, I ran this code a few times and it seems to work but stops after a while due to protected files such as system files, "Permission Denied" and then the script just stops, is there a way to modify the code below so that it can handle such protected files or whether it can pass them.

Any advice or help is appreciated.

Set objFS=CreateObject("Scripting.FileSystemObject") 
WScript.Echo Chr(34) & "Full Path" &_ 
 Chr(34) & ","  & Chr(34) & "File Size" &_ 
 Chr(34) & ","  & Chr(34) & "File Date modified" &_ 
 Chr(34) & "," & Chr(34) & "File Date Created" &_ 
 Chr(34) & "," & Chr(34) & "File Date Accessed" & Chr(34) 
Set objArgs = WScript.Arguments 
strFolder = objArgs(0) 
Set objFolder = objFS.GetFolder(strFolder) 
Go (objFolder) 
Sub Go(objDIR) 
  If objDIR <> "\System Volume Information" Then 
    For Each eFolder in objDIR.SubFolders 
        Go eFolder 
    Next    
  End If 
    For Each strFile In objDIR.Files 
        WScript.Echo Chr(34) & strFile.Path & Chr(34) & "," &_ 
        Chr(34) & strFile.Size & Chr(34) & "," &_ 
        Chr(34) & strFile.DateLastModified & Chr(34) & "," &_ 
        Chr(34) & strFile.DateCreated & Chr(34) & "," &_ 
        Chr(34) & strFile.DateLastAccessed & Chr(34) 
    Next  
End Sub 

Then call it from the command line like this.

c:\test> cscript //nologo myscript.vbs "c:\" > "C:\test\Output.csv" 

Thank you :)

© Stack Overflow or respective owner

Related posts about vba

Related posts about vbscript