Old 15th January 2002, 15:00   #1
IGx89
Junior Member
 
Join Date: Jan 2002
Posts: 21
Send a message via ICQ to IGx89
Hkey_current_user

In my app, I store registry values in HKEY_CURRENT_USER. When I uninstall my app, how do I make sure to delete all those values? If the user uninstalls under a different username than he ran the app, then some registry values would be left behind. Putting values in HKEY_CURRENT_USER is common enough, so NSIS must have some easy way to delete them
IGx89 is offline   Reply With Quote
Old 15th January 2002, 22:29   #2
F. Heidenreich
Member
 
F. Heidenreich's Avatar
 
Join Date: Nov 2001
Location: Dresden, Germany
Posts: 97
I think HKCU is intended to be for the current user and as far as I know the current user do not have any access to the registry tree of the others (maybe by HKU but I don't know how).
To give all users the opportunity to uninstall your app properly you could write your registry settings to HKLM like NSIS does it.

~ Florian
F. Heidenreich is offline   Reply With Quote
Old 15th January 2002, 23:32   #3
IGx89
Junior Member
 
Join Date: Jan 2002
Posts: 21
Send a message via ICQ to IGx89
Using HKCU makes things easier for me

Here's how I fixed it:

I just put the following in my app's (WulframPoller) Uninstall section:

IntOp $0 0 + 0
EnumStart:
EnumRegKey $R1 HKEY_USERS "" $0
IntOp $0 $0 + 1
StrCmp $R1 ".DEFAULT" EnumStart
StrCmp $R1 "" EnumEnd
DeleteRegValue HKU "$R1\Software\Microsoft\Windows\CurrentVersion\Run" "WulframPoller"
DeleteRegKey HKU "$R1\Software\Wulfram Poller"
Goto EnumStart
EnumEnd:

Probably could be done in a more efficient way, but it gets the job done
IGx89 is offline   Reply With Quote
Old 16th January 2002, 13:26   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I don't know of any way to delete for every CU there is... What I have done in my app was to create an uninsatller for every user.

This code is located in my user installer. It causes two uninsallers to display in the Add/Remove control panel, one of the program it self, and one for the user's settings.

code:
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\BlazeRunSettings" "DisplayName" "BlazeRun Current User Settings"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\BlazeRunSettings" "DisplayIcon" "$1\BlazeRun.exe"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\BlazeRunSettings" "UninstallString" '"$1\UserUninstall.exe"'



KiCHiK
kichik is offline   Reply With Quote
Old 16th January 2002, 14:33   #5
IGx89
Junior Member
 
Join Date: Jan 2002
Posts: 21
Send a message via ICQ to IGx89
The way I did *should* delete for every user, if I'm understanding the Registry correctly
IGx89 is offline   Reply With Quote
Old 16th January 2002, 16:51   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I must say your way is much better than mine!
Good work.

Live and learn
kichik is offline   Reply With Quote
Old 6th February 2002, 02:38   #7
0mar
Registered User
 
Join Date: Jan 2002
Posts: 30
Thanks for the info. IGx89 - this is a very useful registry tip/scriptlet.

I never would have guessed this would work since when I fire up my registry editor I only see data for the current user in HKEY_USERS...

Just to clarify though: even though I can't see the data (via regedit) for the other profiles, I can still delete it? And it'll work in 9x and NT? (I'll test it out when I can, but external affirmation is soooo comforting )
0mar is offline   Reply With Quote
Old 6th February 2002, 15:36   #8
IGx89
Junior Member
 
Join Date: Jan 2002
Posts: 21
Send a message via ICQ to IGx89
HKEY_CURRENT_USER (HKCU) is only the info for the current user. HKEY_USERS has a list of username keys, under which is the contents of HKCU. Basically, HKCU is a quick, no-hassle shortcut to the current user's info under HKEY_USERS. Hope I'm clear enough

As for working under W9x/NT, it's worked fine for me under W98. I tested NT4, and it seemed to work fine, though I didn't test it too much. It *should* work just fine, since it seems to use HKCU and HKU the same way as W98.
IGx89 is offline   Reply With Quote
Old 6th February 2002, 15:44   #9
0mar
Registered User
 
Join Date: Jan 2002
Posts: 30
Thanks for the info. - I thought HKCU was kind of a shortcut/minor of info. for the current user that's stored elsewhere in the registry. I think a fair bit of the registry keys are linked/mirrored in that fashion.

Glad to hear it works on 98 and NT4 - I can't wait to wrap up upgrading to 1.95 myself and begin testing my installer.

Ahh, the soothing tedium of repetitive installation testing...

Thanks again IGx89.
0mar is offline   Reply With Quote
Old 15th March 2003, 09:51   #10
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
I am not sure about Windows 9x but on NT HKEY_USERS only holds the logged on users and the default user.

Quote:
HKEY_USERS - Registry entries subordinate to this key define the default user configuration for new users on the local computer and the user configuration for the current user.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 15th March 2003, 12:45   #11
IGx89
Junior Member
 
Join Date: Jan 2002
Posts: 21
Send a message via ICQ to IGx89
It took you that long to reply?
IGx89 is offline   Reply With Quote
Old 15th March 2003, 12:47   #12
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Someone refered to this post, from another post and when I read it again I saw that it's wrong. Better late than never

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 15th March 2003, 15:05   #13
0mar
Registered User
 
Join Date: Jan 2002
Posts: 30
It certainly makes sense from a 'security' point of view that other user's registry entries are unavailable under HKEY_USERS in NT.

I don't have 9x anymore, but I think I tested it on there and managed to delete keys from other profiles.
0mar is offline   Reply With Quote
Old 29th November 2005, 13:32   #14
Mikesch
Junior Member
 
Join Date: Oct 2005
Posts: 19
Quote:
Originally posted by IGx89
Using HKCU makes things easier for me

Here's how I fixed it:

I just put the following in my app's (WulframPoller) Uninstall section:

IntOp $0 0 + 0
EnumStart:
EnumRegKey $R1 HKEY_USERS "" $0
IntOp $0 $0 + 1
StrCmp $R1 ".DEFAULT" EnumStart
StrCmp $R1 "" EnumEnd
DeleteRegValue HKU "$R1\Software\Microsoft\Windows\CurrentVersion\Run" "WulframPoller"
DeleteRegKey HKU "$R1\Software\Wulfram Poller"
Goto EnumStart
EnumEnd:

Probably could be done in a more efficient way, but it gets the job done
Nice idea.
But on my systems (2000/XP) I see only the ".DEFAULT" key and the key (SID?) for the current user on the hive "HKEY_USERS". No matter if I logged on as admin or user.
So for this reason the enumeration stops after deleting the keys for the current user.

Any idea about what's wrong with my system?

BTW: Writing application settings to the ".DEFAULT" key to prepare the system for new users has no effect.
If I add a new user he never gets this setting.

I am completely helpless
Mikesch is offline   Reply With Quote
Old 29th November 2005, 17:56   #15
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Nothing is wrong on your computer, that's how it works. You can use EnumUsersReg to load the users' hives manually.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 30th November 2005, 13:10   #16
Mikesch
Junior Member
 
Join Date: Oct 2005
Posts: 19
Thumbs up

Quote:
Originally posted by kichik
Nothing is wrong on your computer, that's how it works. You can use EnumUsersReg to load the users' hives manually.
Many thanks to you, kickik.

That's what I was looking for.

Allow me still two further questions:

Is there an easy way to call this functions in uninstall section without copying them and adding the un. prefix to the function name?

The hive "HKU\.DEFAULT" does not work as I had expected.
If I add a new user to my system he does not get the settings I wrote to "HKU\.DEFAULT" at installation time.
Any suggestion how to ad this for new users?

Mikesch
Mikesch is offline   Reply With Quote
Old 30th November 2005, 14:27   #17
Fretje
Junior Member
 
Join Date: Nov 2005
Posts: 13
Has anybody thought about the fact that, if the user who is running the uninstaller doesn't have administrative rights, the installer won't be able to delete the registry values of the other users?

Greetings,

Fretje
Fretje is offline   Reply With Quote
Old 1st December 2005, 07:55   #18
Mikesch
Junior Member
 
Join Date: Oct 2005
Posts: 19
Quote:
Originally posted by Fretje
Has anybody thought about the fact that, if the user who is running the uninstaller doesn't have administrative rights, the installer won't be able to delete the registry values of the other users?

Greetings,

Fretje
Yes, I thought about this fact.

I need the above behaviour for the case of installing my application as an administrator for all users.
If a normal user installs my application he does this only for itself and does not affects any other user settings.

In this moment I work on my uninstaller section to prevent uninstalling by the user if the application was installed by an administrator.

Mikesch
Mikesch is offline   Reply With Quote
Old 2nd December 2005, 11:10   #19
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
You can put the functions in a macro and insert once for the installer and once for the uninstaller.
code:
!macro func un
Function ${un}blah
FunctionEnd
!macroend
!insertmacro blah ""
!insertmacro blah "un."

I don't know why HKU\.DEFAULT doesn't work.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 3rd December 2005, 08:43   #20
stb
Senior Member
 
Join Date: Mar 2004
Location: Germany, Paderborn
Posts: 177
IIRC: HKEY_CURRENT_USER can be roaming in Windows networks using a domain controller. Therefore I think it's a bad idea to delete those data for all/other users. HKEY_CURRENT_USER should only contain user settings. Because you cannot know how many network computers (0 or more) have your software installed I would let that data alone. Giving some option to uninstall user settings for the current user may be ok. Or you may give each user the possibility to remove that data by some small uninstall_userdata.exe/regclean.exe separately (an admin could push this to something logon.bat if he wants to clear the whole network).
stb is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump