VBScript Issue Help Required.
        Posted  
        
            by MalsiaPro
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by MalsiaPro
        
        
        
        Published on 2010-02-17T10:04:49Z
        Indexed on 
            2010/06/09
            5:02 UTC
        
        
        Read the original article
        Hit count: 256
        
I need a script that can run and pull information from any drive on a Windows operating system (Windows Server 2003), listing all files and folders which contain the following fields: The server is quite big and is within our domain.
The required information is:
- Full file path (e.g. C:\Documents and Settings\user\My Documents\testPage.doc)
- File type (e.g. word document, spreadsheet, database etc)
- Size
- When Created
- When last modified
- When last accessed
Also the script will need to convert that data to a CSV file, which later on I can modify and process in Excel. I can imagine that this data will be huge but I still need it. I am logged in as an administrator on the server and the script will need to also process protected files. As in previous posts I have read that the script will stop if such files are processed. I need to make sure that not a single file is skipped.
Please note I have asked this question before but still have not got a working script.
This is the script I got so far, file Test.vbs:
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
I am currently using the command-line to run it:
c:\test> cscript //nologo Test.vbs "c:\" > "C:\test\Output.csv"
The script is not working. I don't know why.
© Stack Overflow or respective owner