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

  • Home
  • SEARCH
  • 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 3997802
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:26:47+00:00 2026-05-20T07:26:47+00:00

I have a vb script that processes text files on a server, however, very

  • 0

I have a vb script that processes text files on a server, however, very occasionally without any apparent reason, the script gets stuck in a loop.

Files are uploaded by clients via ftp (smallish about 2 – 10 kb), a .Net service that is watching the ftp folder kicks off an executable (written in VB6), the executable moves the file from the ftp folder to a folder where it is processed. At this point the exe kicks off the vb script. 98% of the time the script runs without issue.

When the infinite loop occurs I kill the exe process. The odd thing is that when I re-kick off the process manually (by copying it back to the the folder that’s being watched) the exact same file it goes through without issue.

In short the script opens the file into a text stream then it loops through the TextStream object until its AtEndOfStream property is true. Within the loop it creates a new file with some additional information added, now whenever the infinate loop situation occurs the temp file doesnt contain any of the sourcefile data, just the extra data added by the script, for example, the following code works 98% of the time:

Do While ts.AtEndOfStream <> True
    sOriginalRow = ts.ReadLine
    sUpdatedRow = sOriginalRow & ",Extra_Data"
    NewFile.WriteLine sUpdatedRow
Loop

So if the source file contains:

LineA
LineB
LineC

The new file is created conbtaining:

LineA,Extra_Data
LineB,Extra_Data
LineC,Extra_Data

but when the problem occurs and the new file is instantly populated with thousands of rows of

,Extra_Data
,Extra_Data
,Extra_Data
,Extra_Data
,Extra_Data
…

its as though the AtEndOfStream property never becomes true.

My initial thought is that the source file is getting corrupted somehow but when these source files are reprocessed they are fine. Another thought is that the textstream object is getting incorrectly created, and not picking up the new line character, maybe because the file is locked by another process or something.

The only way I have found to replicate the behaviour is to comment out the ReadLine part of the code, which in effect prevents the current line number from incrementing. e.g.

sOriginalRow = "" 'ts.ReadLine

Can anyone offer any suggestions?

  • 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-20T07:26:48+00:00Added an answer on May 20, 2026 at 7:26 am

    Well, as you say, the only thing I can offer are suggestions, not real answers:

    Maybe your stream bumps against an ObjectDisposedException (not catchable in VBScript), so the EndOfStream condition gets <> True but not False.

    For the sake of the experiment, you could try to change Do While ts.AtEndOfStream <> True to Do While Not ts.AtEndOfStream or Do Until ts.AtEndOfStream but my bio-logical circuits tell me that is probably not going to work.

    There is another problem described where the stdIn and stdErr are conflicting with each other causing a hang in particular situations.

    Could you also please answer the comment of Tmdean. On Error Resume Next could create a real mess: If ts.AtEndOfStream returns Null or garbage (because ts was destroyed for example) it will not become True and will cause a loop in Foreverland.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that processes file uploads. The script tries to organise
I have a script that retrieves objects from a remote server through an Ajax
I have a script that works fine on my test server (using IIS6). The
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I have a script that checks responses from HTTP servers using the PEAR HTTP
I have a script that takes a table name and generates a control file
I have a script that renders graphs in gnuplot. The graphs all end up
I have a script that successfully encrypts a credit card. I need it to
I have an script that receives an encrypted url and from that generates a
I have a script that needs to extract data temporarily to do extra operations

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.