2012-01-30 75 views

回答

6

上述2个答案显示PowerShell解决方案。 您也可以从CMD.EXE命令提示符中轻松完成此操作。

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

很明显,您需要修改您的signtool选项以满足您的需求。重要的位是%F将迭代地保存每个.MSI文件的名称。

如果要从批处理文件中运行该命令,则%必须加倍,因此%F在两个位置都变为%% F.

2

假设你知道什么命令行参数,你需要的MSI签名工具,你可以得到所有的MSI给定文件夹下,这样的:

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 
    } 
} 
3

下面是使用代码签名证书的例子(我只$证书中的一个证书):

$cert = Get-ChildItem -Path Cert: -CodeSigningCert -Recurse 
Get-ChildItem -Path C:\MsiFolder -Filter *.msi -Recurse | Set-AuthenticodeSignature -Certificate $cert 
0

只有一个密码提示!

$signExe = 'C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe' 
$files = gci 'C:\Temp\*' -Include *.msi | %{('"{0}"' -f $_.FullName)} 
$fingerprint = '00000000000000000000000000000000000000000' 
$timestampUrl = 'http://rfc3161timestamp.globalsign.com/advanced' 

$filesInputArg = $files -join " " 
.$signExe sign /tr $timestampUrl /td SHA256 /sha1 $fingerprint $filesInputArg 
相关问题