'CWS File Cleaner.vbs -- deletes the CoolWebSearch (CWS) shield-DLL and BHO from the hard disk ' 'DO NOT REMOVE THIS HEADER! ' 'Copyright Andrew ARONOFF & Rossano FERRARIS, 04 February 2008 ' http://www.silentrunners.org/sr_cwsremoval.html 'This script is provided without any warranty, either expressed or implied 'It may not be copied or distributed without permission '** YOU RUN THIS SCRIPT AT YOUR OWN RISK! ** 'HEADER ENDS HERE Option Explicit Dim Wshso : Set Wshso = WScript.CreateObject("WScript.Shell") Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Dim oReg : Set oReg = GetObject("winmgmts:root\default:StdRegProv") Dim strSysVer, intErrNum, strURL, strOS, strOSLong, strIFN, strFFN, strLine, intMB Const SysFolder = 1, WinFolder = 0, TempFolder = 2 Const DQ = """" Dim strFPSF : strFPSF = Fso.GetSpecialFolder(SysFolder).Path & "\" 'FullPathSystemFolder Dim strFPWF : strFPWF = Fso.GetSpecialFolder(WinFolder).Path & "\" 'FullPathWindowsFolder 'Winver.exe is in \Windows under W98, but in \System32 for other O/S's 'trap GetFileVersion error for VBScript version < 5.1 On Error Resume Next If Fso.FileExists (strFPSF & "\Winver.exe") Then strSysVer = Fso.GetFileVersion(strFPSF & "\Winver.exe") Else strSysVer = Fso.GetFileVersion(strFPWF & "\Winver.exe") End If intErrNum = Err.Number On Error Goto 0 Err.Clear 'if old VBScript version If intErrNum <> 0 Then 'store dl URL strURL = "http://tinyurl.com/6sgo2" 'explain the problem intMB = MsgBox ("This script requires VBScript 5.1 or higher " &_ "to run." & vbCRLF & vbCRLF & "The latest version of VBScript " &_ "for Windows 2000 & Windows XP" & vbCRLF & "can be " &_ "downloaded at: " & strURL & vbCRLF & vbCRLF &_ "Press " & DQ & "OK" & DQ & " to direct your browser to " &_ "the download site or" & vbCRLF & DQ & "Cancel" & DQ &_ " to quit.", vbOKCancel + vbExclamation,"Unsupported VBScript Version!") 'if dl wanted now, send browser to dl site If intMB = 1 Then Wshso.Run strURL 'quit the script WScript.Quit End If 'error encountered? 'use WINVER.EXE file version to determine O/S If Instr(Left(strSysVer,3),"4.1") > 0 Then strOS = "W9x" : strOSLong = "Windows 98" ElseIf Instr(Left(strSysVer,5),"4.0.1") > 0 Then strOS = "NT4" : strOSLong = "Windows NT 4.0" ElseIf Instr(Left(strSysVer,8),"4.0.0.95") > 0 Then strOS = "W9x" : strOSLong = "Windows 95" ElseIf Instr(Left(strSysVer,3),"5.0") > 0 Then strOS = "W2K" : strOSLong = "Windows 2000" ElseIf Instr(Left(strSysVer,3),"5.1") > 0 Then strOS = "WXP" : strOSLong = "Windows XP" ElseIf Instr(Left(strSysVer,3),"4.9") > 0 Then strOS = "W9x" : strOSLong = "Windows Millennium" ElseIf Instr(Left(strSysVer,3),"5.2") > 0 Then strOS = "WS2K3" : strOSLong = "Windows Server 2003" ElseIf Instr(Left(strSysVer,3),"6.0") > 0 Then strOS = "WVA" : strOSLong = "Windows Vista" Else intMB = MsgBox ("The " & DQ & "File Cleaner" & DQ & " script cannot " &_ "determine the operating system." & vbCRLF & vbCRLF & "Click " &_ DQ & "OK" & DQ & " to send an e-mail to the author, providing the following information:" &_ vbCRLF & vbCRLF & "WINVER.EXE file version = " & strSysVer & vbCRLF & vbCRLF & "or click " & DQ &_ "Cancel" & DQ & " to quit.",49,"O/S Unknown!") If intMB = 1 Then Wshso.Run "mailto:Andrew%20Aronoff%20" &_ "<%63%77%73%66%63.%6F%73.%76%65%72.%65%72%72%6F%72@" &_ "%73%69%6C%65%6E%74%72%75%6E%6E%65%72%73.%6F%72%67>" &_ "?subject=File%20Cleaner%20OS%20Version%20Error&body=" &_ "WINVER.EXE%20file%20version%20=%20" & strSysVer WScript.Quit End If If strOS = "W9x" Or strOS = "WS2K3" Then MsgBox "The detected Operating System is " & DQ & strOSLong &_ DQ & "." & vbCRLF & "This script can only run on " &_ "Windows NT 4.0, Windows 2000, Windows XP and Windows Vista." &_ vbCRLF & vbCRLF & "This script will exit.", vbOK + vbExclamation,"Wrong O/S!" WScript.Quit End If 'ask user about Admin rights intMB = MsgBox ("This script requires Administrator rights." & vbCRLF &_ vbCRLF & "Are you logged on as an Administrator?", vbYesNo + _ vbQuestion, "Are you an Administrator?") If intMB = 7 Then WScript.Quit 'explain what will happen intMB = MsgBox ("This script will delete the CWS shield-DLL, if you " &_ "know its name." & vbCRLF & "It will also delete the CWS BHO " &_ "(Browser Helper Object), if you know its name." & vbCRLF & vbCRLF &_ "You can delete one or the other or both." & vbCRLF & vbCRLF &_ "You don't need to know where the files are located." & vbCRLF &_ "If the script can't find them, it will tell you." & vbCRLF & vbCRLF &_ "Press " & DQ & "OK" & DQ & " to continue or" &_ vbCRLF & Space(10) & DQ & "Cancel" & DQ & " to quit.",vbOKCancel +_ vbQuestion,"Delete files or Quit?") If intMB = 2 Then WScript.Quit 'take care of the shield-DLL 'input the file name strIFN = InputBox ("Enter the name of the shield-DLL file" & vbCRLF &_ "(the path is optional) :","Shield-DLL File Deleter","") If strIFN <> "" Then 'locate the file If Fso.FileExists(strIFN) Then strFFN = strIFN ElseIf Fso.FileExists(strFPSF & strIFN) Then strFFN = strFPSF & strIFN ElseIf Fso.FileExists(strFPWF & strIFN) Then strFFN = strFPWF & strIFN Else 'file couldn't be located -- offer to continue strFFN = "" intMB = MsgBox (DQ & strIFN & DQ & " was not found." &_ vbCRLF & vbCRLF & "Press " & DQ & "OK" & DQ &_ " to continue with deletion of the BHO or" & vbCRLF &_ Space(10) & DQ & "Cancel" & DQ & " to quit.", _ vbOKCancel + vbExclamation, "Shield-DLL not found! Quit?") If intMB = 2 Then WScript.Quit End If 'shield-DLL found? 'if file was found If strFFN <> "" Then 'delete it CAD strFFN 'if now deleted If Not Fso.FileExists(strFFN) Then 'say so MsgBox "The Shield-DLL file: " & DQ & strFFN & DQ & vbCRLF &_ "has been deleted.",vbOKOnly,"Shield-DLL Deleted!" Else 'if it's still there 'say so and offer to continue intMB = MsgBox ("The Shield-DLL file " & DQ & strFFN & DQ & vbCRLF &_ "could *not* be deleted." & vbCRLF & vbCRLF & "Do you want to " &_ "try to delete the BHO file?" & vbCRLF & vbCRLF & "Press " &_ DQ & "OK" & DQ & " to continue or" & vbCRLF & Space(10) &_ DQ & "Cancel" & DQ & " to quit.",vbOKCancel + vbCritical,_ "Shield-DLL *Not* Deleted! Quit?") If intMB = 2 Then WScript.Quit End If 'shield-DLL exists? End If 'shield-DLL found? End If 'shield-DLL name input? 'take care of the BHO 'input the file name strIFN = InputBox ("Enter the name of the BHO file" & vbCRLF &_ "(the path is optional) :","BHO File Deleter","") If strIFN <> "" Then 'locate the file If Fso.FileExists(strIFN) Then strFFN = strIFN ElseIf Fso.FileExists(strFPSF & strIFN) Then strFFN = strFPSF & strIFN ElseIf Fso.FileExists(strFPWF & strIFN) Then strFFN = strFPWF & strIFN Else 'file couldn't be located, so quit MsgBox DQ & strIFN & DQ & " was not found.", _ vbOKOnly + vbExclamation, "BHO not found!" WScript.Quit End If 'BHO found? 'delete the BHO CAD strFFN 'if now deleted If Not Fso.FileExists(strFFN) Then 'say so MsgBox "The BHO file: " & DQ & strFFN & DQ & vbCRLF &_ "has been deleted.",vbOKOnly,"BHO Deleted!" Else 'if it's still there 'say so and quit MsgBox "The BHO file " & DQ & strFFN & DQ & vbCRLF &_ "could *not* be deleted.",vbOKOnly + vbCritical,"BHOL *Not* Deleted!" WScript.Quit End If 'BHO exists? End If 'BHO input? 'clean up Set Fso=Nothing Set Wshso=Nothing 'Cacls-Attrib-Del Sub CAD (strFileName) Wshso.Run "cmd.exe /c cacls " & DQ & strFileName &_ DQ & " /E /G everyone:F",0,TRUE Wshso.Run "cmd.exe /c attrib -h -r -s " & DQ & strFileName &_ DQ,0,TRUE Wshso.Run "cmd.exe /c del " & DQ & strFileName & DQ,0,TRUE End Sub 'R00 '2004/09/29 'R01 'added VBS & O/S version detection, query about Admin rights, 'continuation if input box cancel button pushed 'R02 'added /E parameter to CACLS to avoid Y/N prompt (internationalization 'hassles) 'R03 'changed mailto address to be script-specific 'R04 'modified mailto address 'changed URL for WSH d/l (for W2K & WXP) 'added Vista compatibility