Archive: EnumUsersReg + RegUnLoadKey


EnumUsersReg + RegUnLoadKey
Hi all!

I found this very usefull header file EnumUsersReg.nsh (http://nsis.sourceforge.net/EnumUsersReg) and did some slight changes to it for my purposes.

Now the basic concept for logged-off users is to load their NTUSER.dat into the registry under HKU. This is done by the RegLoadKey Function (http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx). After reading/ editing the Reg values the hive is unloaded. This is done by the RegUnLoadKey Function (http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx).

So far, so good.
One major problem I encountered is that if the installer crashes before the loaded hives were unloaded again they remain which leads to the situation that the respective users cannot logg-on (or only with a temporary profile).

I tried to check if there are any "old" hives on installer start. But I have difficulties as I cannot remove/ unload them with RegUnLoadKey. Only a reboot removes them "automatically".

My question now is if there is any method other than to reboot the system to unload unwanted remained hives from the Registry?
Are there any additional things to make this technique most robust/ stable?

Many thanks for any help, hints, tipps etc.!

Gunther


Hi,

here is the answer to my previous problem.

I forgot to set the needed privileges before using 'advapi32::RegUnLoadKey'.
You have to call the macro (from EnumUsersReg.nsh) '_EnumHKU_AdjustTokens' to set the privileges for the current process as it is a new and other one than the one originally loaded the hive.

To check/ debug if the privileges are missing check the return value of 'advapi32::RegUnLoadKey'. If it is '1314' then you are lecking the privileges and have to call the macro first.

So this is just for the archive if someone might have the same problem one day ...!

Gunther