Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sign all the msi file which are under folder?

I am using signtool to sign my msi.

How to recursively search all the msi in a folder and subfolder then sign them all?

like image 634
Samselvaprabu Avatar asked Jan 30 '12 12:01

Samselvaprabu


People also ask

How do I sign an MSI file?

msi on the Web server, you should sign the files with your digital certificate and private key, Mycert. cer and Mycert. pvk, using the SignTool utility. For more information about using the SignTool utility, see CryptoAPI Tools Reference in the Microsoft Windows Software Development Kit (SDK).

How do I sign a DLL certificate?

To sign your add-in with your own certificate, you first need to purchase a digital signature from a digital certificate vendor. Once you obtain a certificate (cer) or Personal Information Exchange (pfx) file, you can sign your DLL(s) using signtool.


3 Answers

The previous 2 answers show a PowerShell solution. You can accomplish this easily enough from a CMD.EXE Command Prompt as well.

for /r "yourRootFolder" %F in (*.msi) do signtool sign /a "%F"

Obviously you need to modify your signtool options to suit your needs. The important bit is %F will iteretively hold the name of each .MSI file.

If you want to run the command from within a batch file, then the % must be doubled, so %F becomes %%F in both places.

like image 164
dbenham Avatar answered Oct 09 '22 20:10

dbenham


Here's an example using a code signing certificate (I have only one certificate in $cert):

$cert = Get-ChildItem -Path Cert: -CodeSigningCert -Recurse
Get-ChildItem -Path C:\MsiFolder -Filter *.msi -Recurse | Set-AuthenticodeSignature -Certificate $cert
like image 20
Shay Levy Avatar answered Oct 09 '22 22:10

Shay Levy


Assuming you know what command line parameters you need for the MSI signing tool are you can get all MSIs under a given folder like this:

Get-ChildItem -recurse -path C:\MsiFolder -Include *.msi | ForEach-Object {
    $msiPath = $_.FullName
    $output = & the_msi_sign_tool.exe -msifile $msiPath -parameterB -parameterC 2>&1
    if ($LASTEXITCODE -ne 0) {
        Write-Error $output
    }
}
like image 28
Andy Arismendi Avatar answered Oct 09 '22 20:10

Andy Arismendi