Working with Group Policy Preferences: Managing INI Files

    Configuring installed software products is a rather tedious procedure. And if you take into account the fact that in most organizations identical settings should not be installed on one machine, but at least on several employees of the same department, then if you configure applications using the graphical interface, this whole process can take a long time. Given this point, we can immediately come to the conclusion that it would be desirable to try to automate the process of setting up programs so that you can centrally manage the configurations of your users' applications.
    By and large, there are several methods that allow you to configure software products without resorting to using the user interface. These methods include generating scripts for automating certain tasks using a scripting language, such as Windows PowerShell or AutoIT, and the subsequent distribution of such scripts using Group Policy. In addition, if software products generate certain parameters in the system registry of operating systems, you can centrally predetermine such settings using the corresponding Group Policy Preference item. In the end, some programs may use configuration files to store their settings, changing which you can make some changes to the settings of such products.
    Today we will focus on the last method described above. In other words, from the material in this article you will learn about what INI files are, how they can affect the tuning of programs, and also, naturally, I will talk about centralized tuning of INI files. But first things first.

    What are .ini files?


    INI, they are also Initialization-files, designed to store configuration data of some components of Windows operating systems, as well as third-party applications. Such files were created in the first versions of Windows operating systems, but after a while, or more precisely, in 1995, with the advent of Windows 95, they began to gradually supplant the system registry, and now they are used almost exclusively in third-party applications who are in no hurry to change the ways of storing configuration data.
    In fact, there is no official specification of the format of this file on the Internet, or it is simply very difficult to find. But here you can not worry too much, because the structure of INI files is so simple and intuitive that even regular users who can’t even understand the programming languages, but who have never even understood HTML, can manually create and configure such files. .
    These configuration files consist of so-called sections, inside of which are located the parameters themselves, called properties. Such files can contain both empty lines, which are convenient to use in order for INI files to be readable, as well as semicolon comments and even section headings enclosed in square brackets. It is more than obvious that in such configuration files it is impossible to use several different properties with the same name, but I believe that for a long time no one has made such banal errors. It should also be noted that with the help of a backslash you can combine several lines, and they will be processed as one whole line.
    Here, in principle, there’s nothing more to talk about configuration INI files, so we will slowly move on to the practical part of this article. Before we begin to configure such files, it will be correct if the files themselves are examined. It will also talk about how they change after making changes using the settings dialog boxes of the software itself. Take the notorious Opera browser as an example.

    Localization of changes in program settings using INI files


    First of all, download this software product and install it. I will not describe this, since the procedure is more than obvious. Now, before we start to change something, open the folder in which the configuration files of this program are located. I think those who use this browser by default know that the operaprefs.ini file is located in the % Userprofile% \ AppData \ Roaming \ Opera \ Opera folder . And by the way, this file can also be configured using a special configuration page that can be called directly from the browser - this is the opera: config page. As you can see in the following illustration, there are many options available for configuration. Before making any changes, I suggest backing up this file to a separate backup folder.


    Fig. 1. A page with browser configuration parameters
    Now let's see how you can configure this browser in organizations. Of course, I hope that your Opera is not the default browser, but if you are not so lucky, now you will learn how to effectively configure this browser.
    Solely as a test, we will change several properties from the User Prefs section . Suppose, for example, that this is the “Chat Room Splitter” property with a value of 80 , not 100, a check box will be selected for the option“Click to Minimize,” and the cookie folder, that is, the “Cookies Directory” property , will be changed to “% Userprofile% \ AppData \ Roaming \ Opera \ Opera \ Cookies” . Three parameters with different values, I think, will be more than enough.
    Open the modified INI configuration file, move to the [User Prefs] section and find the changed properties. As the following illustration shows, the Chat Room Splitter property now has a value of 80, the Click to Minimize property has a value of 1, and the Cookies Directory property now has {SmallPreferences} Cookies as a folder .


    Fig. 2. Modified ini file
    We will replace the changed file with the file whose backup copy was created, and proceed to configuring the INI files using the functionality of the Group Policy preferences functionality.

    Group Policy Preferences Node “INI Files”


    The extension of the client side "INI files" allows you to add new properties to sections of INI or INF files. In addition, you can also replace existing properties, delete the properties themselves, sections, or even the INI files themselves. We will just replace the values ​​of some properties.
    The preference element of INI files is subject to change both in the user configuration and in the computer configuration, so here, when designing your GPOs, before creating preference items, be sure to consider whether the INI file should be changed only by the user who signed in or same .ini files must be configured before logging in. In addition, it should be noted that the gpprefcl.dll library is responsible for this extension of the client side, and GUID {74EE6C03-5363-4554-B161-627540339CAB} is associated with this CSE.
    In the following procedure, you will learn how to change the same three parameters of the operaprefs.ini configuration file.means of functionality of group policy, or more precisely, using the corresponding element of preferences. So, in order to centrally change the properties of the current configuration file, you need to perform the following steps:
    1. First of all, in the Group Policy Management snap-in , we create a group policy object, which will be called Opera INI-files Preferences and will be solely responsible for the settings of the INI file of this browser, immediately bind the object itself to the entire domain (the changes, however, will be it’s only entered into the user’s configuration, but for simplicity it will be done just now), and after that we’ll open the Group Policy Management Editor.
    2. Consequently, while the node " configuration Windows " ( Windows Settings ) user configuration, select node " INI-files " ( INI files ), and then, as shown in the following illustration, the context menu, as usual, select the command "Create" , and then " File .ini » ( "Ini file» ):


      Fig. 3. Creating an INI File Group Policy Preference Item
    3. Since there will be only modified some values of existing properties, sufficient to stop in on the action "Update» ( the Update ). In the “File Path” text box , specify the exact path and name of the file itself. In our case, as already known, this is C: \ Users \ Administrator \ AppData \ Roaming \ Opera \ Opera \ operaprefs.ini . But after all, if you think about it, not every user has a profile with the name "Administrator", so that you don’t have any problems using this preference item, I recommend that you use variables. Be sure to note that when using Group Policy preferences, you cannot use generally accepted variables. Therefore, you have to take advantage of the fact that they provide preference opportunities. There is such a variable as% LogonUser%, which substitutes the name of the user who has logged in to the string. It is for this reason that we need to create our preference elements in the user configuration node. In general, we should get the following value: C: \ Users \% LogonUser% \ AppData \ Roaming \ Opera \ Opera \ operaprefs.ini . Since we want to change the values ​​of three properties in the User Prefs section we know, it is necessary to indicate it in the text field "Section Name" , that is, " Section name ", without square brackets. We turn to the property itself: in the corresponding text field, specify the value “ Chat Room Splitter ”, since this property needs to be changed. Well, in the text box " Property Value " , which in the original goes as " Property Value ", we indicate our new value, that is, 80 . Properties dialog box of the preference item can be seen below:


      Fig. 4. Properties dialog box for the .ini file preference item
    4. Since the GPO is tied to the entire domain, this preference item will be applied to each company computer. Well, if Opera is not installed on all computers, then users on computers with the distribution of the GPO will simply create an unnecessary file in vain. This should not be, and this can be avoided by using targeting at the element level. In the dialog box, select the target editor must be an element of " Compliance File " ( "Match the File" ) from the dropdown list "match type" that is, " Match of the type " stop on the type of " file exists " ( "file the exists"), and then in the corresponding text field, localize the file with the settings for this browser, that is, the operaprefs.ini file . But only if you select a file using the appropriate dialog box, be sure to note that % LogonUser% is written in the path text box instead of the current user account . Otherwise, the file will be searched for the account you specified, which in almost all cases will lead to an error. Targeting dialog editor is shown in the following figure:


      Fig. 5. Targeting Editor Dialog Box

    It remains to create two more preference items with the same focus on the item level to change the two remaining parameters. I.e:
    • In the first preference item, the property name must be Click to Minimize , and its value must be 1;
    • In the second preference item, the property name is Cookies Directory and the value is {SmallPreferences} Cookies .

    Ultimately, the Group Policy Management Editor window should look like this, as shown in the sixth illustration of this article:


    Fig. 6. Group Policy Management Editor after creating all the preferences.
    But now it’s possible to check whether we managed to modify the existing opera INI file. To do this, update the policy settings using the gpupdate utility , and then you need to localize the desired configuration file. As seen in the latest illustration of this article, the file is changed, and it defines the values that are indicated in the corresponding Group Policy preferences:


    Figure. 7. Modified operaprefs.ini file

    Conclusion


    In this article, you learned about what INI configuration files are and why. Using the Opera browser as an example, we considered changing the settings using one of these files. Well, the most important thing that was discussed in the current article is that you learned about such an interesting element of Group Policy preferences as “ INI files” . In the accompanying example, the modification of three properties of an existing configuration file was considered.
    The most important thing when working with configuration INI files is that you always save the original version of such files before editing the latter in case you overdo it with configuration changes. Rollback is always easier and more painless than a complete reinstallation of the software :)

    Also popular now: