0

I am getting this error:

"C:\se2.vbs(28, 6) Microsoft VBScript runtime error: Input past end of file"

when I run my script (I italicized LINE 28):

Dim strInput
Dim filesys
Dim path
Set filesys=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFSO = CreateObject("Scripting.FileSystemObject")

objStartFolder = "C:\Program Files\Apache Software Foundation\Tomcat 7.0_Tomcat7_1010\webapps\Geniisys\" 'Directory to search
objTempFolder = "C:\Users\njediaz\Desktop\temp\"
objOutputFile = "C:\Users\njediaz\Desktop\output\files.txt"

strInput = InputBox("Enter file to search (case sensitive):")
strSearchFor = strInput

ShowSubfolders objFSO.GetFolder(objStartFolder)

Sub ShowSubFolders(Folder)

   'Wscript.Echo Folder.Path

   For Each objFile in Folder.files

      ' Wscript.Echo Folder.Path & "\" & objFile.Name

       path = Folder.Path & "\" & objFile.Name

If InStr(oFSO.OpenTextFile(path).ReadAll, strSearchFor) > 0 Then

            filesys.CopyFile path , objTempFolder & objFile.Name
        Else
            WScript.Sleep (100)
        END If

   Next

   For Each Subfolder in Folder.SubFolders
       ShowSubFolders Subfolder
   Next
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Script to log common files

Set fs = CreateObject("Scripting.FileSystemObject")
'Log file name
Set logFile = fs.OpenTextFile(objOutputFile, 2, True)
'Directory you want listed
Set folder = fs.GetFolder(objTempFolder)

Set files = folder.Files
  For Each file in files
    logFile.writeline(file.name)
  Next
logFile.close
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Script to delete

Const DeleteReadOnly = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(objTempFolder & "*"), DeleteReadOnly

MsgBox "Done."

Help please! Thanks!

2
  • Are there some folder under 'objStartFolder'? Your code assumes that only data files exist under 'objStartFolder'. If folder exists, your code try to open a path without file part as text file. For example, oFSO.OpenTextFile("C:\Program Files\Apache Software Foundation\Tomcat 7.0_Tomcat7_1010\webapps\Geniisys\someSubDir\") may made same error message. Commented Nov 12, 2014 at 6:03
  • Hi Fumu 7, I tried your suggestion and the code works even it scanned a folder without a text file. Thanks for the help though! Commented Nov 12, 2014 at 7:15

2 Answers 2

1

Looks like one of the files has zero size. Evidence:

Option Explicit

Const ForReading = 1

Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")

Dim oFile
For Each oFile In goFS.GetFolder("..\data\26878933").Files
    WScript.Echo oFile.Path, oFile.Size
    WScript.Echo oFile.OpenAsTextStream(ForReading).ReadAll()
    WScript.Echo "------"
Next

output:

cscript 26878933.vbs
..\data\26878933\a.txt 3
a

------
..\data\26878933\b.txt 0
26878933.vbs(10, 5) Microsoft VBScript runtime error: Input past end of file
Sign up to request clarification or add additional context in comments.

1 Comment

Hi. Yes that's the error indeed! I just found it out. Thanks for the help. I put this IF statement to catch the BLANK TEXT FILE: IF oFSO.GetFile(path).size <> 0 then 'Process text file then search for string. END IF
0

I found out the problem. The error occurred when the script searched for a string in a BLANK TEXT FILE. I tried adding this:

IF oFSO.GetFile(path).size <> 0 then    

    'Process text file then search for string.

END IF

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.