好的,我有一个漂亮的 VBS,它会在巨大的日志文件中搜索某些字符串,但我并不总是想在每个日志文件中搜索每个字符串。我想要一个允许最终用户选择他们想要查找的字符串的 HTA 前端。
这是我的代码示例,它作为 vb 工作得很好,但在这个示例中,我想要牛、山羊、猫、狗等的复选框,并且无论选择多少,脚本都能正确运行..(我的实际脚本有大约 20 个单词可供选择)并且“动物日志文件”的路径和名称目前是一个输入框。我也希望在 hta 中使用它。
Const ForReading = 1
Dim words(7)
Dim msg
words(0) = "cows"
words(1) = "goats"
words(2) = "cats"
words(3) = "dogs"
words(4) = "elephants"
words(5) = "giraffes"
Set objFSO = CreateObject("Scripting.FileSystemObject")
strAnswer = InputBox("Please enter the path & filename for the animal log file:", _
"Create File")
Wscript.Echo strAnswer
Set objFile = objFSO.OpenTextFile( strAnswer, ForReading)
Set inFile = objFSO.OpenTextFile ( strAnswer, ForReading)
strContents = objFile.ReadAll
objFile.Close
Set outFile = objFSO.OpenTextFile( strAnswer &"_parsed-output.txt", 8, True)
Do Until inFile.AtEndOfStream
strSearchString = inFile.ReadLine
For i = 0 To UBound(words)-1
If InStr(strSearchString,words(i)) Then
msg = msg&strSearchString&vbcrlf
End If
next
Loop
inFile.Close
outfile.WriteLine msg
WScript.Echo "Done!"