Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 633313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:10:20+00:00 2026-05-13T20:10:20+00:00

I got the following code to capture information for files on a specified drive,

  • 0

I got the following code to capture information for files on a specified drive, I ran the script againts a 600 GB hard drive on one of our servers and after a while I get the error

Out of String space; “Join”.
Line 34, Char 2

For this code, file script.vbs:

Option Explicit 
Dim objFS, objFld 
Dim objArgs 
Dim strFolder, strDestFile, blnRecursiveSearch 
''Dim strLines 
Dim strCsv 
''Dim i 

''    i = 0 

'   'Get the commandline parameters 
'   Set objArgs = WScript.Arguments  
'   strFolder = objArgs(0) 
'   strDestFile = objArgs(1) 
'   blnRecursiveSearch = objArgs(2) 

    '######################################## 
    'SPECIFY THE DRIVE YOU WANT TO SCAN BELOW 
    '######################################## 
    strFolder = "C:\"  
    strDestFile = "C:\InformationOutput.csv"  
    blnRecursiveSearch = True 

    'Create the FileSystemObject 
    Set objFS=CreateObject("Scripting.FileSystemObject") 
    'Get the directory you are working in  
    Set objFld = objFS.GetFolder(strFolder) 

    'Open the csv file 
    Set strCsv = objFS.CreateTextFile(strDestFile, True)  

''    'Write the csv file 
''    Set strCsv = objFS.CreateTextFile(strDestFile, True) 
    strCsv.WriteLine "File Path,File Size,Date Created,Date Last Modified,Date Last Accessed" 
''    strCsv.Write Join(strLines, vbCrLf) 

    'Now get the file details  
    GetFileDetails objFld, blnRecursiveSearch

''    'Close and cleanup objects 
''  strCsv.Close 

''    'Write the csv file 
''    Set strCsv = objFS.CreateTextFile(strDestFile, True) 
''    For i = 0 to UBound(strLines)  
''    strCsv.WriteLine strLines(i)  
''    Next  

    'Close and cleanup objects 
    strCsv.Close 
    Set strCsv = Nothing 
    Set objFld = Nothing 
    Set strFolder = Nothing 
    Set objArgs = Nothing 


'---------------------------SCAN SPECIFIED LOCATION------------------------------- 
Private Sub GetFileDetails(fold, blnRecursive)
Dim fld, fil
dim strLine(4)

on error resume next
    If InStr(fold.Path, "System Volume Information") < 1 Then
        If blnRecursive Then
            'Work through all the folders and subfolders
            For Each fld In fold.SubFolders
                GetFileDetails fld, True 
                If err.number <> 0 then
                    LogError err.Description & vbcrlf & "Folder - " & fold.Path
                    err.Clear 
                End If
            Next
        End If

        'Now work on the files
        For Each fil in fold.Files
            strLine(0) = fil.Path
            strLine(1) = fil.Size
            strLine(2) = fil.DateCreated
            strLine(3) = fil.DateLastModified
            strLine(4) = fil.DateLastAccessed

        strCsv.WriteLine Join(strLine, ",")


            if err.number <> 0 then
                LogError err.Description & vbcrlf & "Folder - " & fold.Path & vbcrlf & "File - " & fil.Name
                err.Clear 
            End If
        Next
    End If
end sub

Private sub LogError(strError)
dim strErr
    'Write the csv file
    Set strErr = objFS.CreateTextFile("C:\test\err.log", false)
    strErr.WriteLine strError
    strErr.Close

    Set strErr = nothing

End Sub

RunMe.cmd

wscript.exe "C:\temp\script\script.vbs"

How can I avoid getting this error? The server drives are quite a bit <????> and I would imagine that the CSV file would be at least 40 MB.

Edit by Guffa:
I commented out some lines in the code, using double ticks (”) so you can see where.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:10:20+00:00Added an answer on May 13, 2026 at 8:10 pm

    This line joins all the lines into a huge string and writes to the file:

    strCsv.Write Join(strLines, vbCrLf)
    

    Instead, write the lines one by one:

    For i = 0 to UBound(strLines)
       strCsv.WriteLine strLines(i)
    Next
    

    Edit:
    To write directly to the file without storing the lines in an array first, you open the file before calling GetFileDetails, and write the string to the file instead of adding it to the array:

    ...
    'Open the csv file
    Set strCsv = objFS.CreateTextFile(strDestFile, True)
    
    'Now get the file details
    GetFileDetails objFld, blnRecursiveSearch 
    
    'Close and cleanup objects
    strCsv.Close
    ...
    

    In the loop in the subroutine you write to the file

    ...
    For Each fil in fold.Files
      strLine(0) = fil.Path
      strLine(1) = fil.Size
      strLine(2) = fil.DateCreated
      strLine(3) = fil.DateLastModified
      strLine(4) = fil.DateLastAccessed
    
      strCsv.Write Join(strLine, ",")
    Next
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 322k
  • Answers 322k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can do: SELECT user1 FROM TAB WHERE user2=id UNION… May 14, 2026 at 12:49 am
  • Editorial Team
    Editorial Team added an answer Exceptions are a special kind of error that isn't directly… May 14, 2026 at 12:49 am
  • Editorial Team
    Editorial Team added an answer You should probably take a look at one of the… May 14, 2026 at 12:49 am

Related Questions

I've got the following string: [global::System.CodeDom.Compiler.GeneratedCodeAttribute(System.Data.Design.TypedDataSetGenerator, 2.0.0.0)] I need to alter it to look
I've got code similar to the following... <p><label>Do you have buffet facilities?</label> <asp:RadioButtonList ID=blnBuffetMealFacilities:chk
I get a MediaException (Prefetch error: -5) when executing the following code on a
Given the following string, I'd like to parse into a list of first names
Java can often infer generics based on the arguments (and even on the return

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.