'************************************************************************ ' File: AutoVerifyRegconfig.vbs (WSH in VBScript) ' Author: M. I. Gallant ' Date: 06/17/2002 ' Site: http://home.istar.ca/~neutron/wsh ' ' Configures win32 registry with "Verify Signature" verb for ' specified list of file-types supporting Authenticode signing. ' Requires wsh 5.6 ' Edit "autoverifyscript" for the location of the "autoverifysig.vbs" script ' Default file types configured are vbs, js and exe '************************************************************************ Option Explicit Const autoverifyscript = "c:\scriptaids\autoverifysig.vbs" 'edit this for your install path to autosignwiz.vbs Dim WshShell, fso, scriptinfo, ProgIDs, result, changes, signkey, signcmd, i signcmd = "wscript.exe " & autoverifyscript & " ""%L""" ProgIDs = Array("VBSFile", "JSFile", "exefile") ' file types to modify changes = "" scriptinfo = "****** AutoVerifyRegconfig.vbs *******" & vbCrLf & vbCrLf & _ "This script extends the shortcut menu of certain files with a " & vbCrLf & _ """Verify Signature"" selection (verb). Changes are automatically make" & vbCrLf & _ "to registry for file-types that support Authenticode signatures." & vbCrLf & _ "The command associated with ""Verify Signature"" depends " & vbCrLf & _ "on a script file ""autoverifysig.vbs"" which should be installed" & vbCrLf & _ "before executing this shortcut configuration script." & vbCrLf & vbCrLf & _ "Do you wish to continue?" result = MsgBox(scriptinfo, vbYesNo+vbInformation, "About autoverifyregconfig.vbs") If result = vbNO Then WScript.Quit End If '------- Check for installation of autoverifysig.vbs script ---- Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(autoverifyscript) Then MsgBox """" & autoverifyscript & """ shortcut command script was found. " & vbCrLf & vbCrLf & _ "Proceeding with registry configuration .... ", vbOKOnly+vbInformation, "Check autoverifysig.vbs install" Else MsgBox """" & autoverifyscript & """ shortcut command script was NOT found. " & vbCrLf & vbCrLf & _ " - install the required ""autoverifysig.vbs"" script to any directory " & vbCrLf & _ " - edit the ""autoverifyscript"" variable above for your chosen directory " & vbCrLf & _ " - run this configuration script again. " & vbCrLf & vbCrLf & _ "Exiting this script .... ", vbOKOnly+vbExclamation, "Check autoverifysig.vbs install" WScript.Quit End If Set fso = Nothing '------- End check for autoverifysig.vbs script -------------- For i=0 to UBound(ProgIDs) changes = changes & "HKEY_CLASSES_ROOT\" & ProgIDs(i) & "\Shell\Verify Signature\Command " & vbCrLf & _ vbTab & signcmd & vbCrLf & vbCrLf Next result = MsgBox ("Configure registry with these settings?" & vbCrLf & vbCrLf & _ changes & vbCrLf & _ "Configure these changes now?? ", vbYesNo+vbExclamation, "Verify Signature Registry Configuration") If result = vbNO Then WScript.Echo "You have decided NOT to modify the registry for signature verification modifications" WScript.Quit End If Set WshShell = CreateObject("WScript.Shell") For i = 0 to UBound(ProgIDs) signkey = "HKCR\" & ProgIDs(i) & "\Shell\Verify Signature\Command\" 'WScript.Echo "signkey " & signkey & vbCrLf & "signcmd " & signcmd If KeyExists(signkey) Then 'WScript.Echo signkey & " exists " & WshShell.RegRead(signkey) If WshShell.RegRead(signkey) = signcmd Then WScript.Echo signkey & " is already configured and up-to-date" else WScript.Echo "Updating " & signkey WshShell.RegWrite signkey, signcmd , "REG_EXPAND_SZ" End If else WScript.Echo "Generating key " & signkey WshShell.RegWrite signkey, signcmd , "REG_EXPAND_SZ" End If Next MsgBox "Registry configuration complete", vbOKOnly+vbInformation, "Verify Signature Registry Configuration" Set WshShell = Nothing Function KeyExists(key) Dim key2 On Error Resume Next key2 = WshShell.RegRead(key) If Err <> 0 Then KeyExists = False Else KeyExists = True End If On Error GoTo 0 End Function