Creating WDTF Scenarios

You can begin your WDTF-based scenarios by creating an instance of the IWDTF2 aggregation interface, which contains DeviceDepot and SystemDepot properties.

To collect one or more target objects, use the IWDTFDeviceDepot2 interface, and use the Query method with the Simple Data Evaluation Language (SDEL).

A script might also examine specific targets by using the IWDTFTarget2::Eval method. After you choose the targets, control them by using one or more action interfaces.

Before you start to develop WDTF scenarios, you must install WDTF. See WDTF Quick Start for more information.

The following sections in this topic describe how to create basic WDTF scenarios.

Simple WDTF Scenario

The following VBScript code sample (WDTF_Sample1.vbs) shows a simplified scenario that uses WDTF to enable and disable every non-phantom device. A non-phantom device is any physically present device. For complete samples, see Sample WDTF Scenarios.


Set WDTF = WScript.CreateObject("WDTF.WDTF")
For Each Device In WDTF.DeviceDepot.Query("IsPhantom=false AND IsDisableable")
    On Error Resume Next
    Set DevMan = Device.GetInterface("DeviceManagement")
    If err <> 0 Then
 DevMan.Disable()
 DevMan.Enable()
    End If
Next

You can run this scenario by running CScript.exe WDTF_Sample1.vbs.

Storing Target Information by Using Context

Some programming languages, such as VBScript, do not easily manage object references. To simplify this management in WDTF, each target provides a Context property that you can use to store arbitrary key/value pairs, including references to active objects. This property is especially useful for storing action interfaces so you can use them later. The following VBScript code example stores an IWDTFSimpleIOStressAction2 action within a named Context item.


deviceObj.Context("IWDTFSimpleIOStressAction2") = SimpleIOObj

Later, your scenario can stop, pause, or restart the IWDTFSimpleIOStressAction2 interface by accessing it through Context again, as the following code example shows.


Device.Context("IWDTFSimpleIOStressAction2").Stop

Detecting Phantom Devices

Phantom devices are devices that were physically installed on the computer in the past but are not currently present. For example, a phantom device may be a USB mouse that has been unplugged. To speed up and simplify re-installation of a device that is plugged into a computer that is turned on, or removed devices, the Windows operating system keeps the device drivers installed but marks the device as a phantom.

Device-type targets include an IsPhantom attribute (and IsAttached attribute, which is equivalent to IsPhantom=false) that specifies the hardware's physical presence. The following VBScript code example lists a collection of all devices that are physically present in the computer.


Set NonPhantomDevices = WDTF.DeviceDepot.Query ("IsAttached")

For more attribute keywords, see SDEL Tokens.

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft