【发布时间】:2017-12-17 16:09:50
【问题描述】:
我有一个导入证书的简单 PowerShell 脚本:
$certificate_file_name = "C:\Files\Plugins\certi1.cer"
$root_cert_folder_path = 'Cert:\LocalMachine\Root'
try
{
$certificate_obj = Import-Certificate -FilePath $certificate_file_name -CertStoreLocation $root_cert_folder_path
}
catch
{
$ErrorMessage = $_.Exception.Message
write-output $ErrorMessage
}
手动运行脚本时 - 它工作正常。
此外,我有一个 installshield 项目,它有 1 个操作项 - 执行上述脚本。
构建安装程序并运行它后,我收到错误“在模块“PKI”中找到“导入证书”命令,但无法加载该模块。如需更多信息,请运行“Import-Module PKI”。
为什么会这样?如何解决? `
【问题讨论】:
-
我建议您尝试从 cmd 提示符启动您的代码,将命令传递给 powershell.exe,以使其正常工作。我怀疑这就是 installsheild 正在做的事情或类似的事情。
标签: powershell windows-installer installshield