我可以使用 Inno Setup 导入
.cer
文件(证书)吗?
我该怎么做?
我需要为 Windows XP、Windows Vista 和 Windows 7 创建证书安装程序。
实际上,
CertMgr.exe
并非在所有 PC 上都可用,而且它似乎不可再分发(正如@TLama 所暗示的);而且你甚至不需要它。
CertUtil
在每台 Windows 机器(我已经测试过)上都可用,并且运行完美:
[Run]
Filename: "certutil.exe"; Parameters: "-addstore ""TrustedPublisher"" {app}\MyCert.cer"; \
StatusMsg: "Adding trusted publisher..."
将 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;
SlowLearner 和 Martin Prikryl 的回复是正确的。但是,评论指出该命令需要提升的权限。如果您使用
-user
命令,它将访问用户存储,因此不需要提升:
[Run]
Filename: "certutil.exe"; Parameters: "-user -addstore ""Root"" {app}\MyCert.cer"; \
StatusMsg: "Adding root certificate..."