Scripting Provider::ExecuteScriptWithRollback


Executes a script that requires rollback. Used by Microsoft. Provisioning Framework (MPF).

An example of a script that is appropriate for this procedure would be one that creates or updates files. The script can take the form of a file or an inline script block (like the <script> tag of an HTML file).

This procedure creates two intrinsic objects that are available to the script: ProviderXML and ProviderHelper.

Object Name Description
ProviderXML Exposes the IXMLDOMNode interface passed to the provider by a provisioning engine. The XML contains the executeData node, which has all data passed to the provider. The script uses this object to get and return data.
ProviderHelper Exposes the IProvHelper interface that the provider receives from a provisioning engine. The script can use this object to call the methods on that interface.

XML Input Schema

The following code fragment shows the format for sending data to this procedure. For inline scripts, embed the script block in the executeData node. For more information on individual elements and attributes, see the Elements and Attributes table.

<executeData>1..1
  <providerScript language=".." file="..">1..1</providerScript>
  <rollbackScript language=".." file="..">1..1</rollbackScript>
</executeData>

XML Output Schema

ExecuteScriptWithRollback does not return data. However, the called script may add output elements.

Elements and Attributes

The following table describes the XML elements and attributes. Unless otherwise indicated, the data type is string.

Element Description, relationships, and attributes
executeData Description:
Encapsulates the procedure's input data.

Child:
providerScript (minOccurs="1" maxOccurs="1")

providerScript Description:
Encapsulates the script to be executed. The script can take the form of a file name (with path) or an inline script block that resembles the <script> section of an HTML file.

File example:

<providerScript language='JavaScript' file="1">c:\test.js</providerScript>

Inline script example:

<executeData>
		<file>c:\test.xml</file>
		<data>Hello World</data>
		<providerScript language='VBScript'>
				<![CDATA[
						REM Create <file> and load it with <data>.
						set fil = ProviderXML.selectSingleNode("executeData/file")
						set dat = ProviderXML.selectSingleNode("executeData/data")
						Call ProviderHelper.SetRollbackData( "file", fil.text )
						Set FSO = CreateObject( "Scripting.FileSystemObject" )
						Set strm = FSO.CreateTextFile( fil.text )
						Call strm.write( dat.xml )
						Call strm.close()
				]]>
		</providerScript>
</executeData>

For inline scripts, it is important to avoid conflicts with XML. If the script contains characters such as "<" and ">", embed the script in a CDATA node.

Parent:
executeData

Attribute:

file Optional. Boolean that indicates whether the body of this node is a file ('1'). If this attribute is set to any other value or not specified, the script is assumed to be inline.
language Required. ProgId of the script engine to load and use to run the specified script. The script engine must be a COM object that has the OLEScript registry key and implements the script engine interfaces.
rollbackScript Description:
Encapsulates the rollback script. The script can take the form of a file name (with path) or an inline script block that resembles the <script> section of an HTML file.

File example:

<rollbackScript language='JavaScript' file='1'>c:\testRollback.js</rollbackScript>

Inline script example:

<rollbackScript language="VBScript">
		<![CDATA[
				REM Delete the file created by the <providerScript>.
				fil = ProviderHelper.GetRollbackData( "file" )
				Set FSO = CreateObject( "Scripting.FileSystemObject" )
				Call FSO.DeleteFile( fil )
		]]>
</rollbackScript>

For inline scripts, it is important to avoid conflicts with XML. If the script contains characters such as "<" and ">", embed the script in a CDATA node.

Parent:
executeData

Attribute:

file Optional. Boolean that indicates whether the body of this node is a file ('1'). If this attribute is set to any other value or not specified, the script is assumed to be inline.
language Required. ProgId of the script engine to load and use to run the specified script. The script engine must be a COM object that has the OLEScript registry key and implements the script engine interfaces.

Remarks

Scripts that receive data from the executeData node of the provisioning request must use the ProviderXML object to get that data.

Rollback scripts should use the ProviderHelper object to get data since the ProviderXML object will no longer contain any data unless the procedure element had saveDataForRollback='1'. Most typically, ProviderHelper is used to save data in the providerScript node and retrieve it in the rollbackScript node. For the Provisioning Engine to save rollback data correctly, rollback data saved with ProviderHelper must have a coerced data type other than VARIANT.

See Also

ExecuteScript, IProvHelper, Scripting Provider


Up Top of Page
) 1999-2002 Microsoft Corporation. All rights reserved.