Finding an Existing Instance in the Configuration

To edit the properties of a component Instance already in your runtime or to remove that Instance completely, you can find an Instance by its display name using the get command. This command creates a new variable if it does not already exist. The following example shows how to do this.

xpecmd> load cfg "c:\myimages/image.slx"
xpecmd> get myInst cfg.Instances "User Account"
xpecmd> myInst.Properties("cmiUserName") = "Steven"

In cases where there is more than one Instance of the same component in a runtime, the additional Instances are automatically renamed "Component #2", and so on. In the previous Multiple User Accounts example, the Instance for John's Account has the Display Name "User Account #2". This is the name you would pass to the get command if you want to retrieve that Account. The get command can accept a Configuration object, and will automatically search its Instances collection.

xpecmd> get myInst cfg "User Account #2"

To remove this instance, you can either use the remove command to remove the instance by name, or you can call the Instances.Remove method to remove it by index number. The following example shows how to do this.

xpecmd> cfg.Instances.Remove(myInst.Index)
xpecmd> remove cfg.Instances "User Account #2"         (These two instructions are equivalent)

To list the Instances in your configuration, use the show command. The following example shows how to do this.

xpecmd> show cfg.Instances

This displays a sorted list of all the Instances in your configuration, sorted by Display Name, and each Instance's index number in the collection. Sorting the list by name makes the list easier to read and search through. You can also sort by index number by specifying the optional /n switch, and you can have the output pause every 25 lines with the optional /p switch. Pausing prevents long lists from scrolling out of your command buffer. The following example shows how to do this.

xpecmd> show cfg.Instances /n /p

Last updated on Wednesday, October 18, 2006

© 2006 Microsoft Corporation. All rights reserved.