A company I work for sometimes uses super mandatory profiles for their users. Unfortunately this can cause lots of issues with user settings not being saved at log off and so on. To work around this a .reg file is run at startup. For some of these settings regmon was used to record making the settings change and a reg file created from this. The trouble with this is their are lots of duplicate entries making it larger and larger each time this has been done. By the way I didn't implement this procedure I just have to live with it.
I am going to attempt to clean this down to it's minimum but am wondering if anyone has done this before. What I am thinking is, I read the lines into an 2d array so:
[HKEY_CURRENT_USER\Software\CELCAT\CT\SAT\Settings]
"OpenTTVS"="0"
"OTTFrmW"="420"
"OTTFrmH"="321"
becomes:
[HKEY_CURRENT_USER\Software\CELCAT\CT\SAT\Settings], "OpenTTVS"="0"
[HKEY_CURRENT_USER\Software\CELCAT\CT\SAT\Settings], "OTTFrmW"="420"
[HKEY_CURRENT_USER\Software\CELCAT\CT\SAT\Settings], "OTTFrmH"="321"
Then remove duplicates in reverse order so if a setting is changed twice it removes the entries first in the file.
Then sort the array by the hive and output the key every time and the hive when it changes. Sorry if the terminology is wrong.
Will this work? Probably better using a collection rather than an array but you get the idea.