VBScript:对文件夹中的文件进行数字签名抛出错误“无法找到用于解密的证书和私钥”

时间:2017-10-15 07:19:38

标签: vbscript certificate sign digital-certificate mmc

我创建了Signer.vbs文件来执行此功能,下面是VBScript代码,用于为特定文件夹以数字方式签署所有文件。该文件夹包含脚本文件。

Dim sCertificate
Dim sFolder
Dim sStore
Dim objSigner
Dim objFSO
Dim objFolder
Dim colListOfFiles
Dim objFile

sCertificate = "MyCert"
sFolder = "D:\App\Project\VALab\SC\VBSigningProcess\FilesToSign"
sStore = "my"

Set objSigner = WScript.CreateObject("Scripting.Signer")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(sFolder)
Set colListOfFiles = objFolder.Files

For Each objFile in colListOfFiles
    WScript.Echo "File Name : " & objFile.Path & vbnewline & "Certificate : " & sCertificate & vbnewline & "Store : " & sStore
    objSigner.SignFile objFile.Path, sCertificate
Next

以上代码抛出错误在下面的行“无法找到用于解密的证书和私钥,错误代码:8009200C”

  

objSigner.SignFile objFile.Path,sCertificate

位于MMC内的“MyCert”证书。请查看下图。

enter image description here

0 个答案:

没有答案