Option Explicit
Const ForReading = 1
Const ForWriting = 2
Dim strFile
Dim strFind
Dim strFindPlus
Dim objFSO
Dim objRegExp
Dim objMatches
Dim objMatch
Dim strContent
Dim i
Dim p
Dim r
Dim l
Dim f
Dim str
Dim rep
'WScript.Echo "Selected file: " & ChooseFile( )
Function ChooseFile( )
Dim objFSO, objShell, objTempFolder, strTempFileName, strFullTempFileName, objOpenFile, objTextFile, strTempTextFileName
Const TemporaryFolder = 2
Const ForReading = 1
strTempFileName = "OpenFile.hta"
strTempTextFileName = "OpenFile.txt"
Set objFSO= CreateObject("Scripting.FileSystemObject")
Set objTempFolder = objFSO.GetSpecialFolder(TemporaryFolder)
strFullTempFileName=objTempFolder.Path & "\" & strTempFileName
Set objOpenFile = objFSO.CreateTextFile(strFullTempFileName,True)
objOpenFile.writeline("
")
objOpenFile.writeline("Open File")
objOpenFile.writeline("")
objOpenFile.writeline("")
objOpenFile.writeline("")
objOpenFile.writeline("")
objOpenFile.writeline("")
objOpenFile.writeline("")
objOpenFile.writeline("")
objOpenFile.Close
Set objShell = CreateObject("WScript.Shell")
objShell.Run "mshta.exe " & strFullTempFileName,0,True
objFSO.DeleteFile strFullTempFileName, True
Set objShell=Nothing
Set objOpenFile=Nothing
strFullTempFileName = objTempFolder.Path & "\" & strTempTextFileName
Set objTextFile=objFSO.OpenTextFile(strFullTempFileName, ForReading)
ChooseFile = objTextFile.ReadLine
objTextFile.Close
objFSO.DeleteFile strFullTempFileName, True
Set objTextFile=Nothing
Set objFSO=Nothing
Set objTempFolder=Nothing
End Function
strFile = ChooseFile( )
strFind = "\w\w[^;&]"
With WScript.CreateObject("Scripting.FileSystemObject")
If .FileExists(strFile) Then
Set objRegExp = WScript.CreateObject("VBScript.RegExp")
With objRegExp
.IgnoreCase = True
.Global = True
.Pattern = "\w\w(?!;)"
End With
With .OpenTextFile(strFile, ForReading)
strContent = .ReadAll()
.Close
End With
Set objMatches = objRegExp.Execute(strContent)
With .OpenTextFile(strFile, ForWriting)
if left(strContent, 5) <> "