2012-10-05 351 views
7

我可以使用Inno安裝程序導入.cer文件(證書)嗎?使用Inno Setup,如何導入證書.cer文件?

我該怎麼辦?

我需要創建適用於Windows XP,Windows Vista和Windows 7

證書安裝
+0

我想使用與Certmgr.exe實用程序的命令行。它可以與所有的Windows系統一起使用嗎? –

+4

Certmgr.exe不是Windows的一部分,因此您必須將其捆綁到您的安裝程序中。我認爲它應該適用於所有Windows版本,因爲它是Windows SDK的一部分。 –

回答

3

添加Certmgr.exe和yourcertificate.cer進入設置:

[Files] 
Source: CertMgr.exe; DestDir: {app}; Flags: deleteafterinstall 
Source: yourcertificate.cer; DestDir: {app}; Flags: deleteafterinstall 

而在[Run]段,寫這樣的事情:

Filename: {app}\CertMgr.exe; Parameters: "-add -all -c yourcertificate.cer -s -r localmachine trustedpublisher"; Flags: waituntilterminated runhidden; 
+1

如果它是可再發行的... – TLama

+0

在我的情況下,它的自簽名證書。讓行本地機器以root結尾 – YumYumYum

6

其實CertMgr.exe並不適用於所有的PC,此外它不會似乎是可再發行(由@TL的暗示AMA);除此之外你甚至都不需要它。

CertUtil可每個Windows機器上(我已經測試)和完美的作品:

[Run] 
Filename: "certutil.exe"; Parameters: "-addstore ""TrustedPublisher"" {app}\MyCert.cer"; \ 
    StatusMsg: "Adding trusted publisher..." 
+0

您能詳細說明*「每臺Windows機器(我測試過的)」*嗎? –

+0

@MartinPrikryl不可否認,我可以做更多的測試。我昨天才發現這個,所以沒有經過詳盡的測試;到目前爲止只在Win 10機器上。但其中一個是Azure上的虛擬機,2個沒有Visual Studio的普通PC,dotNets等(因此沒有CertMgr.exe可用),然後是我的DevPC,它具有CertMgr,但CertUtil也可以工作。 – SlowLearner

+0

@MartinPrikryl爲什麼在StatusMsg之前添加'\'? – SlowLearner