Modifying Component Resources in XPECMD


Since the release of Feature Pack 2007, we've gotten a few questions about how to modify component resources and properties in XPECMD. There is already some documentation available in the XPeHelp.chm that describes how to work with properties (such as the username property of a User Account instance). Working with component Resources is just as important in many cases, and you can work with them in almost the same way you work with Properties.


Properties and Resources are both collections of data objects that a Component or Instance object owns. As such, you just use VBScript syntax to access them, like you would any other collection. For example, let's say you want to manually disable the FBA/DLL COM Registration resource in Enhanced Write Filter (doing this would prevent EWF from creating its specialized volume in a DISK or RAM configuration). Here's how you do it:


xpecmd> new cfg config

Starting configuration activation at: 11/30/2006 10:32:42 AM...
Info 100: Initializing new configuration
Info 102: Adding base system component to configuration
Info 101: Initializing new component: "Base Component [Version 5.1.2600, R2010]"
CFDB: 0.75 secs, 14 reqs. LAB: 0.31 secs, 12 reqs, 8% hits, 2 entries
Activation complete, elapsed time: 0.84 seconds
No errors or warnings

xpecmd> new myInst = 'inst:enhanced write fitler'
xpecmd> add cfg myInst
xpecmd> show myInst.Resources
Resources: [23 items]
----- ------------
Index: Value
----- ------------
2: FBRegDLL(819):"%11%\ewfdll.dll","ConfigureEwf"
5: File(819):"%11%","ewfdll.dll"
6: File(819):"%11%","ewfinit.dll"
15: File(819):"%12%","ewf.sys"
1: File(819):"%17%","ewf.inf"
16: File(819):"%24%","HORM.DAT" (DISABLED)
23: RawDep(819):"File","ADVAPI32.dll"
18: RawDep(819):"File","certclas.inf"
...


In this example, the FBA DLL/COM Registration is the "FBRegDLL(819)" entry at the top of the list, and its index in the Resources list is 2. You can disable this resource with the following command:


xpecmd> myInst.Resources(2).Disabled = TRUE

Now if you SHOW the resources of myInst again, you'll see the word "(DISABLED)" next to the FBRegDLL entry.


By the way: The FP2007 version of EWF includes built-in support for RAM (Reg) mode, which automatically takes care of disabling the FBA DLL/COM Registration resource for you when you build your runtime. I used this component as an example because people who have used RAM (Reg) mode in SP2 and below are already familiar with going through this process in Target Designer.


Keep in mind that individual resources in a component Instance are not always listed in the same order each time they're loaded into memory. For instance, when I saved the configuration I created in my steps above, then reloaded it, the FBRegDLL entry had moved to index 14. Because of the way Resources are defined, you can't refer to an individual Resource by DisplayName like you can with Properties. As a result, there isn't really any good way to automate this process right now. We will continue to look into ways to improve these processes in the future, however.


- Matt
 


Comments (2)

  1. xdwei says:

    Hi Matt & Andrew,

    Thanks for your hints!

    Recently I don’t want some services startup during OS initialization in one of my rumtime image configuration. I need to switch the StartType of services from the default SERVICE_AUTO_START to SERVICE_DEMAND_START.

    Instead in TD, I have done this via a XPECMD "response file" to find out the resource index of a specific instance in my script for creating configuration.

    Taking "Smart Card" service as an example in my main response file MySYS.rsp:

    [Code]

    new cfg Configuration

    add cfg ‘inst:^Smart card Subsystem’

    GET myInst cfg.Instances "Smart card Subsystem"

    @".XPE USB BootGetResIndexofServiceStart.rsp"

    myRes(ResIdx).Properties("RegValue") = 3

    [/Code]

    the nest response file GetResIndexofServiceStart.rsp:

    [Code]

    ; variable myInst is an Instance object, MUST defined in caller

    new myRes = myInst.Resources

    new ResIdx

    ;FOR EACH Res IN myRes

    ; FOR EACH Prop IN Res.Properties

    ; IF Prop.name = "ValueName" THEN

    ; IF Res.Properties("ValueName") = "Start" THEN

    ; ResIdx = Res.index

    ; EXIT FOR

    ; END IF

    ; END IF

    ; NEXT

    ; IF NOT IsEmpty(ResIdx) THEN

    ; EXIT FOR

    ; END IF

    ;NEXT

    exec FOR EACH Res IN myRes:FOR EACH Prop IN Res.Properties:IF Prop.name = "ValueName" THEN:IF Res.Properties("ValueName") = "Start" THEN:ResIdx = Res.index:EXIT FOR:END IF:END IF:NEXT:IF NOT IsEmpty(ResIdx) THEN:EXIT FOR:END IF:NEXT

    [/Code]

Skip to main content