0
好的,我有一個漂亮的VBS,它將搜索特定字符串的大型日誌文件,但我並不總是希望爲每個字符串搜索每個日誌文件。我想要一個HTA前端,允許最終用戶選擇他們想要查找的字符串。具有HTA前端的VBScript
這裏是我的代碼示例,它的工作原理很棒,但在本例中,我想爲牛,山羊,貓,狗等複選框。並且腳本無論正確運行有多少選擇..(我的實際腳本有大約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!"