signcode-pwd

Command line tool to automate Microsoft’s SignCode tool (prevents the password dialog popping up).

Download Download: signcode-pwd.zip (Freeware, Version 1.02, 53 KB)
Supported Operating Systems: Windows NT 4, 2000, XP, 2003 or higher
Version History

Microsoft has a tool called SignCode to sign any file using a private/public key algorithm. This files can later be verified with Windows APIs. The Internet Explorer also makes use of this possibility when it wants to start ActiveX controls.

Most people use SignCode as a command line tool. This lets them create a batch (.bat) file to do the signing, and maybe include the batch as a post-build step in their development environment. The only problem is that SignCode doesn’t let you supply the certificate password as part of the command line, so it always hassles you with a little password dialog.

SignCode password dialog

To avoid the dialog popping up, I wrote a small command line tool, called signcode-pwd. You start this tool right before SignCode. As parameter you provide the password you want to be filled in the password dialog. signcode-pwd watches the windows processes running and if it finds the SignCode password dialog it automatically completes it. If there are a series of dialogs popping up it all completes them. If the signing process is finished, terminate signcode-pwd.

If you dont want to pass your password as parameter to signcode-pwd, you also can encrypt it and put it into a file. See following screenshot for all provided functions:

signcode-pwd help

Example of how you use signcode-pwd (this could be a post build step):

signcode-pwd.exe -m Xyz089e
SignCode.exe -spc Cert.spc -v My.pvk
-t http://.../timstamp.dll MyFile.exe
signcode-pwd.exe -t

It’s best to write a batch file, which takes as parameter the file which has to be signed and does the whole signing process. An example batch file is included in the download. It looks like this:

@echo off
rem ----------------------------------------
rem TODO: Modify this constants before using
rem ----------------------------------------
set strFile=%1
set strSignCode=c:\CodeSigning\signcode.exe
set strSignCodePwd=C:\CodeSigning\signcode-pwd.exe
set strSpc=c:\CodeSigning\myCredentials.spc
set strPvk=c:\CodeSigning\myPrivateKey.pvk
set strPwd=c:\CodeSigning\myPassword.pwd
set tsUrl= http://timestamp.verisign.com/scripts/timstamp.dll

echo Start signcode-pwd.exe
%strSignCodePwd% -f %strPwd%

echo Execute signcode.exe
%strSignCode% %strFile% -spc %strSpc% -v %strPvk% -t %tsUrl%
if errorlevel 0 goto end_success

:end_error
echo Error occured while signing
%strSignCodePwd% -t
exit 1

:end_success
echo Signing was successfull
%strSignCodePwd% -t

Happy signing!