'********************************************************************* ' File: AutoSignWiz.vbs (WSH in VBScript) ' Author: M. I. Gallant ' Date: 04/30/2002 ' Site: http://home.istar.ca/~neutron/wsh ' Ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform ' /shell/programmersguide/shell_basics/shell_basics_extending/context.asp ' ' Provides drag/drop launching of Authenticode signcode.exe wizard ' with automatic file selection entered. ' ' Use also to extend shortcut context-menu for semi-automation for signing: ' e.g: ' HKEY_CLASSES_ROOT\VBSFile\Shell\Digitally Sign\Command ' wscript.exe c:\scriptaids\autosignwiz.vbs "%L" ' Add this registry setting for any file-types supporting Authenticode ' file signing (exe, dll, cab, ctl, ocx, cat, vbs, js, wsh) ' ' If "signcode.exe" is not on the system path, then configure the ' Const signcodeapp value below for the installed path. ' ' See related registry configuration script: autosignregconfig.vbs '********************************************************************** Option Explicit Dim WshShell, sourcefile, fileargs Const Wiz_Title = "Digital Signature Wizard" ' Window title for wizard Const signcodeapp = "signcode.exe" 'Authenticode tool; adjust to install path if required. set WshShell = WScript.CreateObject("WScript.Shell") Set fileargs = WScript.Arguments If fileargs.Count<1 Then WScript.Echo "autosignwiz.vbs is a drag/drop utility" WScript.Quit End If sourcefile = fileargs(0) 'get dragged file name ' WScript.Echo sourcefile Wshshell.Run signcodeapp ,1 'execute signcode and return While NOT Wshshell.AppActivate(Wiz_Title) ' wait until wizard window is available WScript.Sleep 200 Wend Wshshell.AppActivate(Wiz_Title) 'make sure wizard is still selected WScript.Sleep 200 Wshshell.SendKeys("{ENTER}") 'go to "File Selection" pane WScript.Sleep 100 Wshshell.SendKeys(sourcefile) WScript.Sleep 100 Wshshell.SendKeys("{ENTER}") 'go to "Signing Options" pane '--- Allow user to continue from here, or customize with specific cert -------------------