? "ZapVbs.kix, Version 1.00 for Windows 95/98/NT" ? "Written by Rob van der Woude" ? "http://www.robvanderwoude.com" ? ? "This Kix script can change the file associations for VBScript files to" ? "NotePad, as a " + chr(34) + "poor man's protection" + chr(34) + " against VBScript (e-mail) viruses." ? "Next time you see a Notepad window pop up after double-clicking an e-mail" ? "attachment (which you shouldn't have done!), it may have been an e-mail" ? "virus, stopped by this Kix script's safety precautions." ? ? "This script does not and will not fully protect you against viruses!" ? "It is only meant as a first line of defence. Buy, install and use recent" ? "anti-virus software and make sure you keep it up-to-date." ? ? "DISCLAIMER:" ? "This script changes registry settings." ? "Changing registry settings may cause system failure and/or loss of data." ? "The author of this script cannot be held responsible for any damage" ? "caused by use of this script, or by the inability to use it." ? "Use this script entirely at your own risk." ? ? 'Press "Y" if you accept these terms . . .' ; Quit unless the terms are accepted Get $y If $y <> "Y" Quit 255 EndIf Cls ? "ZapVbs.kix, Version 1.00 for Windows 95/98/NT" ? "Written by Rob van der Woude" ? "http://www.robvanderwoude.com" ? ; Initialize variable $notepad = "" ? "Checking current VBScript file associations:" ? $vbe = ReadValue ("HKEY_CLASSES_ROOT\.vbe", "") If @ERROR = 0 ? ".VBE file type : $vbe" $chgvbe = 0 $chgvbe2 = 0 ; Read the registry to find out which program ; is used by default when a .VBE file is opened $vbecmd = ReadValue ("HKEY_CLASSES_ROOT\$vbe\Shell\Open\Command", "") If @ERROR = 0 ? ".VBE association : $vbecmd" ; Check if NotePad is already associated with .VBE $pos = InStr($vbecmd, "notepad.exe") If $pos ; Store the path to notepad, so we ; won't need to search for it later $notepad = Substr($vbecmd, 1, $pos + 10) Else ; Set variables to remember to change ; the association for this extension $chgvbe = 1 $chgstr = ".VBE" EndIf EndIf ; Repeat the process for "Open2" $vbecm2 = ReadValue ("HKEY_CLASSES_ROOT\$vbe\Shell\Open2\Command", "") If @ERROR = 0 ? ".VBE association : $vbecm2" $pos = InStr($vbecm2, "notepad.exe") If $pos $notepad = Substr($vbecm2, 1, $pos + 10) Else $chgvbe2 = 1 $chgstr = ".VBE" EndIf EndIf EndIf ? ; Repeat for .VBS extension $vbs = ReadValue ("HKEY_CLASSES_ROOT\.vbs", "") If @ERROR = 0 ? ".VBS file type : $vbs" $chgvbs = 0 $chgvbs2 = 0 $vbscmd = ReadValue ("HKEY_CLASSES_ROOT\$vbs\Shell\Open\Command", "") If @ERROR = 0 ? ".VBS association : $vbscmd" $pos = InStr($vbscmd, "notepad.exe") If $pos $notepad = Substr($vbscmd, 1, $pos + 10) Else $chgvbs = 1 If ($chgstr = ".VBE") $chgstr = ".VBE and .VBS" Else $chgstr = ".VBS" EndIf EndIf EndIf $vbscm2 = ReadValue ("HKEY_CLASSES_ROOT\$vbs\Shell\Open2\Command", "") If @ERROR = 0 ? ".VBS association : $vbscm2" $pos = InStr($vbscm2, "notepad.exe") If $pos $notepad = Substr($vbscm2, 1, $pos + 10) Else $chgvbs2 = 1 If InStr($chgstr, ".VBE") $chgstr = ".VBE and .VBS" Else $chgstr = ".VBS" EndIf EndIf EndIf EndIf ; Check if any association needs to be changed ; according to the previous part of the script If ($chgvbe OR $chgvbe2 OR $chgvbs OR $chgvbs2) ; If the path to NotePad wasn't found ; in the registry settings we checked ; before, we need to find it now If $notepad = "" ; Check the WINDOWS or WINNT directory first $notepad = "%windir%\notepad.exe" If Dir($notepad) = "" OR @ERROR <> 0 ; If unsuccessful, check the ; SYSTEM or SYSTEM32 directory $notepad = "@LANROOT\notepad.exe" If Dir("@LANROOT\notepad.exe") = "" OR @ERROR <> 0 ; If still unsuccessful, use the ; TYPE command instead of NotePad $notepad = "%COMSPEC% /K TYPE" EndIf EndIf EndIf ? ? "Suggested new association: = $notepad" ; Wrap line if the path is too long to display on 1 single line If Len($notepad) > 23 $crlf = chr(13) + chr(10) Else $crlf = "" EndIf ; Ask for confirmation ? ? "Do you want to change the default association for $chgstr" ? 'files to $notepad "%%1" %%*? ' ? ; Repeat question until valid answer is given $x = 0 Do ; Beep when invalid answer is given If $x Beep EndIf Get $answer $x = 1 Until InStr("yn", $answer) ; Quit unless confired If $answer <> "Y" ? ? "Associations for $chgstr left unchanged" Quit 0 EndIf ; Build association string $assoc = '$notepad "%%1" %%*' ; Change only the associations necessary ; .VBE Open If $chgvbe ? ? "Changing default association for .VBE files to " + $crlf + $notepad + " " + chr(34) + "%%1" + chr(34) + " %%*" $key = "HKEY_CLASSES_ROOT\" + $vbe + "\Shell\Open\Command" $rc = WriteValue( $key, "", $assoc, "REG_SZ") If @ERROR ? "Error writing to registry!" ? "The error code is: @ERROR" ? "Press any key to quit . . ." Get $dummy Quit 1 EndIf $newval = ReadValue ($key, "") ? "Checking new value: " + $crlf + $newval EndIf ; Change only the associations necessary ; .VBE Open2 If $chgvbe2 ? ? "Changing second association for .VBE files to " + $crlf + $notepad + " " + chr(34) + "%%1" + chr(34) + " %%*" $key = "HKEY_CLASSES_ROOT\" + $vbe + "\Shell\Open2\Command" $rc = WriteValue( $key, "", $assoc, "REG_SZ") If @ERROR ? "Error writing to registry!" ? "The error code is: @ERROR" ? "Press any key to quit . . ." Get $dummy Quit 2 EndIf $newval = ReadValue ($key, "") ? "Checking new value: " + $crlf + $newval EndIf ; Change only the associations necessary ; .VBS Open If $chgvbs ? ? "Changing default association for .VBS files to " + $crlf + $notepad + " " + chr(34) + "%%1" + chr(34) + " %%*" $key = "HKEY_CLASSES_ROOT\" + $vbs + "\Shell\Open\Command" $rc = WriteValue( $key, "", $assoc, "REG_SZ") If @ERROR ? "Error writing to registry!" ? "The error code is: @ERROR" ? "Press any key to quit . . ." Get $dummy Quit 3 EndIf $newval = ReadValue ($key, "") ? "Checking new value: " + $crlf + $newval EndIf ; Change only the associations necessary ; .VBS Open2 If $chgvbs2 ? ? "Changing second association for .VBS files to " + $crlf + $notepad + " " + chr(34) + "%%1" + chr(34) + " %%*" $key = "HKEY_CLASSES_ROOT\" + $vbs + "\Shell\Open2\Command" $rc = WriteValue( $key, "", $assoc, "REG_SZ") If @ERROR ? "Error writing to registry!" ? "The error code is: @ERROR" ? "Press any key to quit . . ." Get $dummy Quit 4 EndIf $newval = ReadValue ($key, "") ? "Checking new value: " + $crlf + $newval EndIf Else ? ? "No change was necessary, VBScript files are already disabled on your system." EndIf ? ? "Press any key to end this program . . ." Get $dummy