This HTA script will allow you to browse for a text file and then it will remove all of the duplicate entries found in the text file and write the new results to the active window.
HTA Script:
<Html>
<Head>
<Title>HTA Script</Title>
<Style>
Body {Background-Color: CornSilk}
</Style>
<HTA:Application
Caption = Yes
Border = Thick
ShowInTaskBar = No
MaximizeButton = Yes
MinimizeButton = Yes>
<Script Language = VBScript>
Sub WindowsLoad
Const ForReading = 1
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Text Files|*.Txt"
intResult = objDialog.ShowOpen
If intResult = 0 Then
Wscript.Quit
Else
strFileName = objDialog.FileName
End If
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, ForReading, True)
Do Until objFile.AtEndOfStream
strName = objFile.ReadLine
If Not objDictionary.Exists(strName) Then
objDictionary.Add strName, strName
Loop
objFile.Close
Window.Document.Title = "Duplicates Removed From " & strFileName
For Each strKey in objDictionary.Keys
strHtml = strHtml & "<td><Font color = Green></Font></Td>" & strKey & "</Br>"
Next
DataArea.InnerHtml = strHtml
End Sub
</Script><Body>
<p><h3 align = center><font color='Orange'>Please Visit myITforum.Com</font></h3>
<div></div>
<input Type = "Button" Value = "Browse For File" Name = "Run_Button" onClick = "WindowsLoad"><p></td>
<Span Id = "DataArea"></Span></Body><Div Align = "Center">
<P><A Href="http://myitforum.com/cs2/blogs/dhite">Created For myITforum By Don Hite</A>
Here you will find two PowerShell scripts that will allow you to sort the contents of a text file alphabetically