Consider this scenario:
- Inno Setup installs program named XYZ to Program Files, to be accessed by all users.
- A configuration option within program XYZ allows installation of a registry value to
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
on a per-user basis, to allow users to configure application auto-start to their own preferences. - When uninstalling XYZ, if any user other than the current user has auto-run registry keys set, they will be left over and cause errors next time they log-in.
Questions
- What would be the correct way to remove the appropriate registry values from all user accounts in Inno Setup?
- Would it be appropriate to enumerate over the profiles in HKU and check for the keys and delete them? How would this be done in Inno Setup?
- Lastly, what issues might doing this cause with roaming profiles?
The program XYZ in question is in C#, and can enumerate through the HKU's with the following code, but I'd like to handle the uninstallation completely via Inno Setup and not have to call into a separate executable on uninstall.
private static string GetSIDFromUserName(string userName)
{
var account = new System.Security.Principal.NTAccount(userName);
var identifier = (System.Security.Principal.SecurityIdentifier)account.Translate(typeof(System.Security.Principal.SecurityIdentifier));
var sid = identifier.Value;
return sid;
}
private static string[] GetAllSystemUsers()
{
List<string> names = new List<string>();
SelectQuery query = new SelectQuery("Win32_UserAccount");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject envVar in searcher.Get())
{
names.Add((string)envVar["Name"]);
}
return names.ToArray();
}