Contact Info

Crumbtrail

ActiveXperts.com » Administration » VBScript Collection » Security » Script Signing

Script Signing

Sign All the Scripts in a Folder
Sign a Script Programmatically
Verify Signatures for All the Scripts in a Folder
Verify a Script Signature


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.

Sign All the Scripts in a Folder


Uses the Scripting Runtime Signer object to digitally sign all the scripts in a folder. Requires a valid digital certificate.
Set objSigner = WScript.CreateObject("Scripting.Signer")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("c:\scripts")
Set colListOfFiles = objFolder.Files

For Each objFile in colListOfFiles
    objSigner.SignFile objFile.Path, "IT Department"
Next
	

Sign a Script Programmatically


Set objSigner = WScript.CreateObject("Scripting.Signer") objSigner.SignFile "C:\Scripts\CreateUsers.vbs", "IT Department"
Uses the Scripting Runtime Signer object to digitally sign a script. Requires a valid digital certificate.

Verify Signatures for All the Scripts in a Folder


Verifies that all the scripts in the C:\Scripts folder have been digitally signed.
blnShowGUI = False

set objSigner = WScript.CreateObject("Scripting.Signer")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Scripts\")
Set colListOfFiles = objFolder.Files

For Each objFile in colListOfFiles
    If Right(objFile.Name, 3) = "vbs" Then
        blnIsSigned = objSigner.VerifyFile(objFile.Path, blnShowGUI)
        If blnIsSigned then
            WScript.Echo objFile.Name & " has been signed."
        Else
            WScript.Echo objFile.Name & " has not been signed."
        End If
    End If
Next
	

Verify a Script Signature


Verifies that an individual script has been digitally signed.
blnShowGUI = False

Set objSigner = WScript.CreateObject("Scripting.Signer")
blnIsSigned = objSigner.VerifyFile("C:\Scripts\CreateUser.vbs", blnShowGUI)

If blnIsSigned Then
    WScript.Echo "Script has been signed."
Else
   WScript.Echo " Script has not been signed."
End If