You may need to download the CAPICOM redistributable from Microsoft:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=860ee43a-a843-462f-abb5-ff88ea5896f6
;~ --------------------------------- File Handling --------------------------------- If $CmdLine[0]<1 Then $TheFile = FileSaveDialog('Select File', @ScriptDir,"All (*.*)") Else $TheFile=$CmdLine[1] EndIf Sleep(1000) ;~ --------------------------------- Initialize Error Handler ------------------------ $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ;~ --------------------------------- Create COM objects ------------------------------ $oSignerCode = ObjCreate("CAPICOM.SignedCode.1") $oSigner = ObjCreate("CAPICOM.Signer.1") ;~ --------------------------------- Who Is Signing ---------------------------------- $oSigner.Load ("objectSignCert.p12", "certPassword") ;~ $oSigner.Options = CAPICOM.CAPICOM_CERTIFICATE_INCLUDE_OPTION.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY ;~ --------------------------------- Sign it ----------------------------------------- $oSignerCode.FileName = $TheFile $desc = InputBox("Description","Add a Description.. EX.. My Project Name v.01") if not $desc = "" then $oSignerCode.Description = $desc $oSignerCode.Sign($oSigner) ;~ --------------------------------- TimeStampIt ------------------------------------- $oSignerCode.Timestamp("http://timestamp.verisign.com/scripts/timestamp.dll") ;~ --------------------------------- Clear Memory ------------------------------------ $oSignerCode = "" $oSigner = "" ;~ --------------------------------- Error Handling -------------------------------- Func MyErrFunc() Local $HexNumber=hex($oMyError.number,8) Msgbox(48,@ScriptName,"An error has been encountered" & @CRLF & @CRLF & _ " description: " & @TAB & $oMyError.description & @CRLF & _ " : " & @TAB & $oMyError.windescription & @CRLF & _ " error number: " & @TAB & $HexNumber & @CRLF & _ "last dllerror: " & @TAB & $oMyError.lastdllerror & @CRLF & _ " line number: " & @TAB & $oMyError.scriptline & @CRLF & _ " source: " & @TAB & $oMyError.source & @CRLF & _ " help file: " & @TAB & $oMyError.helpfile & @CRLF & _ " helpcontext: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ;~ to check for after this function returns EndFunc Exit
Ive set this up as a drag and dropOnTo exe...
i wanted to create this because i didn't wanna open up signtool.exe and do pointless clicking every time.
and the scripting.signer.... Just doesn't do Time-stamping....
let me know if theres a problem
I got a little more info and stuff on this madder
to only timestamp useing the capicom.dll (you can only timestamp the file after its been signed)
;~ --------------------------------- File Handling --------------------------------- If $CmdLine[0]<1 Then $TheFile = FileSaveDialog('Select File', @ScriptDir,"All (*.*)") Else $TheFile=$CmdLine[1] EndIf if $TheFile= "" then exit(99) Sleep(1000) ;~ --------------------------------- Initialize Error Handler ------------------------ $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ;~ --------------------------------- Create COM objects ------------------------------ $oSignerCode = ObjCreate("CAPICOM.SignedCode.1") ;~ --------------------------------- What to Time Stamp ------------------------------ $oSignerCode.FileName = $TheFile ;~ --------------------------------- TimeStampIt ------------------------------------- $oSignerCode.Timestamp("http://timestamp.verisign.com/scripts/timestamp.dll") ;~ --------------------------------- Clear Memory ------------------------------------ $oSignerCode = "" ;~ --------------------------------- Error Handling -------------------------------- Func MyErrFunc() Local $HexNumber=hex($oMyError.number,8) Msgbox(48,@ScriptName,"An error has been encountered" & @CRLF & @CRLF & _ " description: " & @TAB & $oMyError.description & @CRLF & _ " : " & @TAB & $oMyError.windescription & @CRLF & _ " error number: " & @TAB & $HexNumber & @CRLF & _ "last dllerror: " & @TAB & $oMyError.lastdllerror & @CRLF & _ " line number: " & @TAB & $oMyError.scriptline & @CRLF & _ " source: " & @TAB & $oMyError.source & @CRLF & _ " help file: " & @TAB & $oMyError.helpfile & @CRLF & _ " helpcontext: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ;~ to check for after this function returns EndFunc Exit
so you can use the "Scripting.Signer" method to sign the file if you wanted too..
http://www.autoitscript.com/forum/topic/124467-verifying-signed-files/page__view__findpost__p__865990
for more info on the objects in the capicom.dll look at
http://msdn.microsoft.com/en-us/library/aa380254(v=VS.85).aspx
Edited by usabrad86, 14 June 2011 - 03:25 PM.





