inno setup - Uninstall auto-run registry entries for all users -


consider scenario:

  • inno setup installs program named xyz program files, accessed users.
  • a configuration option within program xyz allows installation of registry value hkcu\software\microsoft\windows\currentversion\run on per-user basis, allow users configure application auto-start own preferences.
  • when uninstalling xyz, if user other current user has auto-run registry keys set, left on , cause errors next time log-in.

questions

  • what correct way remove appropriate registry values user accounts in inno setup?
  • would appropriate enumerate on profiles in hku , check keys , delete them? how done in inno setup?
  • lastly, issues might doing cause roaming profiles?

the program xyz in question in c#, , can enumerate through hku's following code, i'd handle uninstallation via inno setup , not have call 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(); } 

to delete autorun entry users, use:

procedure deleteautorunentryfromallusers(autorunvaluename: string); var   names: tarrayofstring;   userkey: string;   autorunkey: string;   i: integer; begin   log('enumerating user keys');   reggetsubkeynames(hkey_users, '', names);   log(format('found %d user keys', [getarraylength(names)]));    := 0 getarraylength(names)-1   begin     userkey := names[i];     log(format('user %s', [userkey]));     autorunkey := format('%s\software\microsoft\windows\currentversion\run', [userkey]);      if regvalueexists(hkey_users, autorunkey, autorunvaluename)     begin       log(format('deleting auto-run entry user %s', [userkey]));        if regdeletevalue(hkey_users, autorunkey, autorunvaluename)       begin         log(format('deleted auto-run entry user %s', [userkey]));       end         else       begin         log(format('failed delete auto-run entry user %s', [userkey]));       end;     end;   end; end; 

not sure roaming profiles.


did consider adding autorun entry hkey_local_machine, make application exit based on setting in hkey_current_user (per user preference)?

this way uninstall single hkey_local_machine value. setting in hkey_current_user might left behind.


Comments

Popular posts from this blog

jquery - ReferenceError: CKEDITOR is not defined -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -