SDK: How to add an enhanced detection method into an application deployment type

Update #1: I have attached the sample as a .cs file to make it easier to consume

In my previous post I provided a simple sample on how to create an application with a very basic detection method. If you want to perform more advanced detection, you can leverage the desired configuration management (DCM) SDK to create an extremely rich set of conditions called enhanced detection methods (EHD).

These EHD classes require the DcmObjectModel.dll assembly which is located with the administrator console.

The sample here will demonstrate creating an EHD and adding it to a deployment type. Use the sample program in this post and replace the code between lines 34 and 35 with the code that follows:

Code Snippet
  1. installer.DetectionMethod = DetectionMethod.Enhanced;
  2. EnhancedDetectionMethod ehd = new EnhancedDetectionMethod();
  4. // Get value from this registry setting
  5. RegistrySetting registrySetting = new RegistrySetting(null);
  6. registrySetting.RootKey = RegistryRootKey.LocalMachine;
  7. registrySetting.Key = @"SOFTWARE\MyCompany\MyProduct";
  8. registrySetting.Is64Bit = true;
  9. registrySetting.ValueName = "IsInstalled";
  10. registrySetting.CreateMissingPath = false;
  11. registrySetting.SettingDataType = DataType.Int64;
  13. // Add the setting to the EHD
  14. ehd.Settings.Add(registrySetting);            
  16. // The expected value of the detected registry key
  17. ConstantValue constValue = new ConstantValue("1", DataType.Int64);
  19. // Create the reference to the EHD setting
  20. SettingReference settingRef = new SettingReference(
  21.     application.Scope,
  22.     application.Name,
  23.     application.Version.GetValueOrDefault(),
  24.     registrySetting.LogicalName,
  25.     registrySetting.SettingDataType,
  26.     registrySetting.SourceType,
  27.     false);
  29. settingRef.MethodType = ConfigurationItemSettingMethodType.Value;
  31. // Create a collection of operands, these will be compared in an Expression
  32. CustomCollection<ExpressionBase> operands = new CustomCollection<ExpressionBase>();
  33. operands.Add(settingRef);
  34. operands.Add(constValue);
  36. // Expression to verify that all of the operands meet the ExpressionOperator value            
  37. Expression exp = new Expression(ExpressionOperator.IsEquals, operands);
  39. // Create the rule
  40. Rule rule = new Rule("MyRuleId", NoncomplianceSeverity.None, null, exp);
  42. // Now create the deployment type and bind it to the installer
  43. DeploymentType scriptDT = new DeploymentType(installer, ScriptInstaller.TechnologyId, NativeHostingTechnology.TechnologyId);
  44. scriptDT.Title = "My Application Installer";
  46. ehd.Rule = rule;
  48. // Now add the rule to the detection method.
  49. installer.EnhancedDetectionMethod = ehd;

This will show in the administrator console like this:


This is just one example of the kind of powerful detection you can perform with EHDs.

Similar code can be used for creating requirement rules as well (these are added into your DeploymentType.Rules collection).


Comments (8)

  1. Vaughn Nerdahl says:

    Can you post how to configure the detection method to use the radio button "This registry key must exist on the target..."?

  2. Jim Walsh says:

    Hi Adam,

    Could you provide an example of how create a rule to check to see if a registry key exists?  Looks like it should be simpler than the example you provide here but I cannot see to figure out how to setup the Enhanced Detection Method Rule.


  3. trackerball says:

    What CCM DLLs need to be referenced for this program to compile?

  4. Jack Rudlin says:

    Doesn't seem like it's documented but might also be helpful to others that for file/folder checks the additional properties can also be set.

    ConfigurationItemSettingMethodType.Value,"Version" for instance

    A colleague of mine found these in the XML of SDMpackageDigest column in v_ConfigurationItems

  5. Minde says:

    Would be interesting to know how to add additional clause. I can add ehd.Settings.Add(anotherSetting);, but  not clear what to do with another expression and rule?

  6. Newbie says:


    thanks for this helpful post.

    What I need currently is, to add an additional rule.

    so I want to have 2 different rules, checking for regkey availability. (with an OR function "outside").

    Beside this I also could not figure out, how to set the flag for "This registry setting must exist on the target system to indicate presence of this application".

    I would really appreciate your help on this.


  7. Jonathan Walz says:

    Do you have an example for adding multiple detection methods to a deployment type?

  8. Ludovic says:

    I don't know if you can help me, but I have a question about the detection merhod.
    I'm using Powershell to automate the creation of applications on SCCM 2012 R2 SP1.
    I know how to create only one detection method (File/Folder, Registry, Product Code) using Powershell and it works perfectly.
    But I don't know how to add a second detection clause for the same application and same deployment type.
    Can you help me?
    Thank you in advance ! =)


Skip to main content