Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
The Scripting.Signer object can also be used to programmatically verify the digital signature on a script. To do this, you need to use the VerifyFile method, along with two arguments:
The following script verifies the signature on the file C:\Scripts\CreateUsers.vbs, and suppresses the Security Warning dialog box. The script will return one of two values: True means that the digital signature has been verified, False means either that the script has not been signed or the signature could not be verified.
set objSigner = WScript.CreateObject(
"Scripting.Signer
") blnShowGUI = False blnIsSigned = objSigner.VerifyFile(
"C:\Scripts\CreateUsers.vbs
", blnShowGUI) If blnIsSigned then WScript.Echo objFile.Name &
"has been signed.
"Else WScript.Echo objFile.Name &
"has not been signed.
"End If End If
Alternatively, you might want to use the VerifyFile method to verify the digital signatures on a number of scripts. For example, this script verifies the digital signatures on all the scripts found in the C:\Scripts folder.
set objSigner = WScript.CreateObject(
"Scripting.Signer
") blnShowGUI = False Set objFSO = CreateObject(
"Scripting.FileSystemObject
") Set objFolder = objFSO.GetFolder(
"C:\Scripts
") Set colListOfFiles = objFolder.Files For each objFile in colListOfFiles blnIsSigned = objSigner.VerifyFile(objFile.Name, blnShowGUI) If blnIsSigned then WScript.Echo objFile.Name &
"has been signed.
"Else WScript.Echo objFile.Name &
"has not been signed.
"End If Next
Send us your feedback | « Previous | Next » |