Microsoft VBScript runtime error: Input past end of file error

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

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!

回答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 


回答2:

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 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!