Programmatically Signing a Script

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

WSH 5.6 includes the Scripting.Signer object that allows you to digitally sign a script using another script. To do this you need to:

  • Create an instance of the Scripting.Signer object.
  • Use the SignFile method, specifying both the file name of the script to be signed and the name of the digital certificate to be used to sign the script.

For example, this script uses the IT Department certificate to sign the script C:\Scripts\CreateUsers.vbs.

set objSigner = WScript.CreateObject("Scripting.Signer") objSigner.SignFile "C:\Scripts\CreateUsers.vbs", "IT Department" 

You can also digitally sign a number of scripts at the same time. This script loops through and signs all the files found in the C:\Scripts folder. (The assumption is that the only scripts are stored in C:\Scripts.)

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.Name, "IT Department" Next 

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net