Export (0) Print
Expand All
9 out of 19 rated this helpful - Rate this topic

How to Write a Simple .Adm File for Registry-based Group Policy

Applies To: Windows Server 2003

This section shows you how to create a simple .adm file for delivering registry-based Group Policy settings. The code samples provided are parts of a single .adm file. Please refer to "Language Reference for Administrative Template Files," later in this document for full details about the .adm language.

The sections of the sample .adm file illustrate how to set a registry value to:

  • Turn a feature on or off.

  • Allow the selection of one or more values from a list.

  • Display a list with add and remove buttons.

  • Enter EDITTEXT and static text.

  • Display a numeric list to the administrator.

  • Display a numeric list to the administrator, using a spin control.

  • Display an actionable list to an administrator.

To Set a Registry Value to Turn a Feature ON or OFF

This sample code displays a check box. The value is set in the registry with the REG_DWORD type. By default, the check box is clear. If the check box is selected, it writes the value 1 to the registry. If the check box is clear, it writes the value 0 to the registry.

CLASS USER 
 
CATEGORY!!SampleCategory 
    KEYNAME "SOFTWARE\Policies\Microsoft\ADM_Samples" 
 
    POLICY!!Sample_ADM_FeatureOnOff 
        #if version >= 4 
            SUPPORTED!!SUPPORTED_WindowsXPSP1 
        #endif 
        EXPLAIN!!Sample_ADM_FeatureOnOff_Help 
        VALUENAME "ADM_Sample_FeatureOnOff" 
            VALUEON 1 
            VALUEOFF 0 
    END POLICY 
END CATEGORY

To Set a Registry Value to Allow the Selection of One or More Values from a List

You can use DROPDOWNLIST to display a combo box with a drop-down style list. You can pre-populate the list of items that are displayed in the list and the corresponding registry value to be written for each item in the list.

POLICY!!Sample_ADM_DropDownList 
    #if version >= 4 
        SUPPORTED!!SUPPORTED_WindowsXPSP1 
    #endif 
    EXPLAIN!!Sample_ADM_DropDownList_Help 
    PART!!Sample_ADM_DropDownList DROPDOWNLIST REQUIRED 
        VALUENAME "Sample_ADM_DropDownList" 
            ITEMLIST 
             NAME !!Sample_ADM_DropDownList_Always    VALUE NUMERIC 1 DEFAULT 
             NAME !!Sample_ADM_DropDownList_WorkStationOnly    VALUE NUMERIC 2 
             NAME !!Sample_ADM_DropDownList_ServerOnly    VALUE NUMERIC 3 
         END ITEMLIST 
    END PART 
END POLICY

To Set a Registry Value to Display a List with Add and Remove Buttons

You can use registry-based Group Policy to display a list box that contains Add and Remove buttons.

By default, only one column appears in the list box, and for each entry, a value is created where the name and value are the same. For example, a name entry in the list box creates a value called name that contains data labeled name.

POLICY!!Sample_ADM_ListBox 
    #if version >= 4 
        SUPPORTED !!SUPPORTED_WindowsXPSP1 
    #endif 
    EXPLAIN!!Sample_ADM_ListBox_Help 
    PART!!Sample_ADM_DropDownList LISTBOX 
        KEYNAME "Sample_ADM_ListBox" 
    END PART 
END POLICY

To Set a Registry Value for EDITTEXT and Static Text

This setting allows the user to type alphanumeric text in an edit field. The text is set in the registry with the REG_SZ type.

The following code is an example of how you can use the EDITTEXT PART type.

POLICY!!Sample_ADM_EditText 
    #if version >= 4 
        SUPPORTED !!SUPPORTED_WindowsXPSP1 
    #endif 
    EXPLAIN!!Sample_ADM_EditText_Help 
    PART!!Sample_ADM_EditText EDITTEXT 
        VALUENAME "ADM_Sample_EditText" 
    END PART 
END POLICY

To Set a Registry Value for Displaying a Numeric List to the Administrator

To display a list of numbers from which administrators can select one of the predefined numeric values, you can use a NUMERIC PART type.

POLICY!!Sample_ADM_Numeric 
 
    #if version >= 4 
 
        SUPPORTED !!SUPPORTED_WindowsXPSP1 
 
    #endif 
 
    EXPLAIN!!Sample_ADM_Numeric_Help 
 
    PART!!Sample_ADM_Numeric NUMERIC 
 
        VALUENAME "ADM_Sample_Numeric" 
 
    END PART 
 
END POLICY

To Set a Registry Value for Displaying a Numeric List to the Administrator, Using SPIN Control

To display a list of numbers from which administrators can select one of the predefined numeric values, you can use a SPIN control.

POLICY!!Sample_ADM_Spinner 
    #if version >= 4 
        SUPPORTED !!SUPPORTED_WindowsXPSP1 
    #endif 
    EXPLAIN!!Sample_ADM_Spinner_Help 
    PART!!Sample_ADM_Spinner NUMERIC 
        VALUENAME "ADM_Sample_Spinner" 
        MIN 5 MAX 23 DEFAULT 14 SPIN 3 
    END PART 
END POLICY

To Set a Registry Value to Display an ActionList to an Administrator

To specify a set of arbitrary registry changes to make in response to a control being set to a particular state, you can use the ACTIONLIST option.

POLICY!!Sample_ADM_ActionList 
    #if version >= 4 
        SUPPORTED !!SUPPORTED_WindowsXPSP1 
    #endif 
    EXPLAIN!!Sample_ADM_ActionList_Help 
    ACTIONLISTON 
        KEYNAME "SOFTWARE\Policies\Microsoft\ADM_Sample\ActionOnList" 
            VALUENAME "Action1" 
            VALUE NUMERIC 1 
        KEYNAME "SOFTWARE\Policies\Microsoft\ADM_Sample\ActionOnList" 
            VALUENAME "Action2" 
            VALUE NUMERIC 7 
        KEYNAME "SOFTWARE\Policies\Microsoft\ADM_Sample\ActionOnList" 
            VALUENAME "Action1" 
            VALUE NUMERIC 100 
    END ACTIONLISTON 
    ACTIONLISTOFF 
        KEYNAME "SOFTWARE\Policies\Microsoft\ADM_Sample\ActionOnList" 
            VALUENAME "Action1" 
            VALUE NUMERIC 0 
        KEYNAME "SOFTWARE\Policies\Microsoft\ADM_Sample\ActionOnList" 
            VALUENAME "Action2" 
            VALUE NUMERIC 0 
        KEYNAME "SOFTWARE\Policies\Microsoft\ADM_Sample\ActionOnList" 
            VALUENAME "Action1" 
            VALUE NUMERIC 0 
    END ACTIONLISTOFF 
END POLICY

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.