FAQ : Configuration Manager Integration


In-Context Launch of Custom Action DLLs (right-click actions)
  • Q: I want to launch a custom assembly DLL using a right-click action and pass it information like the properties of the item selected in the console. How do I do that?
    • A: the SDK documentation talks about how to create custom actions, but focuses more on the concept that you're launching something based on the SMSDialogBase form or something similar which has native access to the properties associated with the object selected in the console. What if you've created your own form and it's not derived from a ConfigMgr form base? You can still get access to those properties if you simply emulate the SMS dialogs by accepting the appropriate parameters. By default, Config Mgr will assume you're deriving from one of its form types which has the following method signature:
public static void Method(object, ScopeNode, ActionDescription, IResultObject, PropertyDataUpdated, Status)
  • If you're going to use your own form type, you will simply create a signature that accepts these parameters. See "Configuration Manager AssemblyType Action" in the SDK for more info about these. Of course, you will need to include the appropriate namespaces so that your code knows about these object types...

  • Q: When doing a query for objects in the SCCM database, ExecuteQuery returns an IResultObject, but I don't know whether the query returned 0, 1, or more than one object, and I can't use the "Count" property because it throws an exception. How can I determine how many IResultObjects were returned?
    • A: ExecuteQuery is a bit tricky this way. Even if your query returned 0 results, you get an IResultObject back from the method. Usually, you have to loop through the object using a "foreach" to determine how many objects you got back. Here is a handy bit of code to help you determine how many objects were in the result set, then to do something with them. The only problem is that it incurs an additional query to the database to get a count first, but it's likely quicker than looping through the entire result set and incrementing a counter manually. Of course, if you're not interested in a specific count of how many items returned, you can just loop through the results using a "foreach" and if it doesn't loop, you didn't have results...
                    // Execute the query
                    IResultObject computerCheck = this.wqlConnManager.QueryProcessor.ExecuteQuery("Select count(*) from SMS_R_SYSTEM");
                    int numResults = 0;

                    // Look in the results to get the count value from the query
                    foreach (IResultObject ro in computerCheck)
                        numResults = ro["Count"].IntegerValue;

                    if (numResults > 0)
                        //since there were results, run the query for what you need
                        IResultObject resComputers = this.wqlConnManager.QueryProcessor.ExecuteQuery("Select * from SMS_R_SYSTEM");

                        foreach (IResultObject roComp in resComputers)
                            //do something
                        //no results were returned
                catch (SmsException ex)
                    //handle the exception

Task Sequence Editor
  • Q: Clicking the Help button in the task sequence editor causes an exception when I'm using a custom task step.
    • A: This is because the task sequence editor, like many dialogs in the ConfigMgr console, uses a file called DialogsHelpInfo.xml to determine what help information to display to the user when they click the help button. The current context of the page the user is on when clicking the help button determines what help information is displayed. The fact that you've added a custom action means that the DialogsHelpInfo.xml file does not have the current page context listed, so when you click Help, ConfigMgr doesn't understand what Help is to be displayed, and therefore shows the exception. For information on how to fix this, see the developer notes for Creating Custom Task Sequence Steps.

OEM Deployment Integration
  • Q: Is there a way that I can call 32-bit or 64-bit utilities in a task step based on the target machine's processor architecture?
    • A: Yes. Use the PROCESSOR_ARCHITECTURE environment variable in the path to your utility (both in the physical file structure of your toolkit package and in the XML file referencing your utilities. The OemDeployment.vbs script will automatically replace the variables with the appropriate values it gets from the system environment. Here is an example:
           <Task Order="0" Executable="myutil.exe" CommandType="EXE" WorkingDirectory="tools\%PROCESSOR_ARCHITECTURE%" >
           And your directory structure should match the environment variable strings, such as:
  • Note: This requires that your executables be named the same regardless of the procesor type they require. If your executables are named differently and the naming difference is not the same as the environment variable strings, it would probably be best to just create a batch file that branches to the appropriate utility based on processor, and just call the batch file from the command line in the XML like this:

           <Task Order="0" CommandType="CMDorBAT" WorkingDirectory="" Executable="myscript.bat">

SMS/SCCM Installs
  • Q: How can I check to see in which directory the SCCM site server or admin console is installed.

Related Links

Last edited Aug 10, 2009 at 9:54 PM by rhearn, version 3


No comments yet.