Microsoft VBScript运行时错误:输入文件末尾错误 [英] Microsoft VBScript runtime error: Input past end of file error

查看:160
本文介绍了Microsoft VBScript运行时错误:输入文件末尾错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到此错误:

C:\se2.vbs(28,6)Microsoft VBScript运行时错误:输入文件末尾

当我运行脚本时(第28行以斜体显示):

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

如果InStr(oFSO.OpenTextFile(path).ReadAll,strSearchFor)> 0然后

            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."

请帮助!谢谢!

推荐答案

我发现了问题所在。当脚本在空白文本文件中搜索字符串时发生错误。我尝试添加以下内容:

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

这篇关于Microsoft VBScript运行时错误:输入文件末尾错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆