2012-01-30 76 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 
相關問題