SignFile Method

Switch View :
ScriptFree
Windows Script Host
SignFile Method

Signs a script using a digital signature.


                      Object.
                      SignFile (FileName, Certificate, Store)
                    
Arguments

object

Scripting.Signer

FileName

A string containing the name of the script file.

Certificate

A string designating the author's certificate name.

Store

An optional string designating the name of the certificate store. Typically certificates that contain private keys — i.e., certificates you can use for code signing — are in a certificate store called "my". The default value is "my".

Remarks

In order to sign a digital signature, the author must have a valid certificate.

Example

Description

The following example demonstrates not only signature checking but also the command-line argument.

<job>
<runtime>
<named name="file" helpstring="the file to sign" required="true" type="string"/>
<named name="cert" helpstring="the name of the signing certificate" required="true" type="string"/>
<named name="store" helpstring="the name of the certificate store" required="false" type="string"/>
</runtime>
<script language="vbscript">
Dim Signer, File, Cert, Store
If Not (WScript.Arguments.Named.Exists("cert") And WScript.Arguments.Named.Exists("file")) Then
     WScript.Arguments.ShowUsage
     WScript.Quit
End If
Set Signer = CreateObject("Scripting.Signer")
File  = WScript.Arguments.Named("file")
Cert  = WScript.Arguments.Named("cert")
If WScript.Arguments.Named.Exists("store") Then
     Store = WScript.Arguments.Named("store")
Else
     Store = "my"
End If
Signer.SignFile File, Cert, Store
</script>
</job>

See Also

Concepts

Reference

Community Content

TedMac
Format for Certificate store and how is it created?

For the signer.signfile, objsigner.signfile and similar methods, what certificate store is required? How is it created? Running these examples I get a message that the certificate and private key cannot be found. Yet I have openssl, keytool and other stores. Please define the creation and form of the certificate store required for this method. A "how-to" would be fabulous.

Thanks, Ted