Archive: DeleteRegKey


DeleteRegKey
Hello Everybody,

during my installation I want to delete a key in

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB

This works fine under Win98 and WinME with the commant:

DeleteRegKey HKEY_LOCAL_MACHINE "Enum\USB\Vid_074d&Pid_3556"


under Win2000 with the command:
DeleteRegKey HKEY_LOCAL_MACHINE "System\CurrentControlSet\Enum\USB\Vid_074d&Pid_3556"
i´ve got following problem:
even logged in as administrator, i don´t have authorisation to
delete a key in the registry. (On a new / clean W2k)
:cry:
now my question is:
is there any possibility to change authorisation during
an installation with NSIS ?

hope anybody can help me
best regards
rio


You would also get this problem on NT I expect since both use a "proper" security model and protect system resources. No ordinary user will be allowed to delete that key, only an administrator will be able to. Therefore, as is the case with many installers, the user running the installer will need to be a local administrator.

A process cannot elevate it's only permission level, that would bypass the security model. A user (and processes run by that user) only has the permissions that they have been granted by an administrator (or other user with sufficient permissions)


Hi Sunjammer,

the problem is, even logged in as administrator I can´t delete
the reg key. The authorisations in the registry for administrators are set to "read only" on a new win2k (I don´t have tested it under NT). Only a user "system" ?!? have permission to write :igor:
The funny about is that I can change the authorisation level to "full access" (as administrator). If I change the authorisation level the installer will work fine. Now I want do this automatically without
change authorisation levels manually. Can I change the levels within the installer (when the user is an administrator of course), or is there an other way to delete registry keys.

greetings
rio


The thing is I have to wonder why you want to do this. The key you want to change is deliberately not accessible by default because only the system account (ie. device drivers running as system, and the kernel itself) should ever touch that part of the registry.

Anyway, what you are really asking is "Is there an NSIS function that can change the security setting of a registry key" - answer = No.

I wrote a tiny extension DLL for someone a while back that removed all security on a registry key (that is explicitly what that person wanted) which might be of use to you (download it), but to be honest I think if you go around changing the security of that key on a system your installer is running on you'd better have a very good reason.


@Sunjammer

thank you for your help,
:)
Now I have found a correct way to solve my problem.
rio
:D


If it's something that other people would find useful please post your solution here (or PM me and I'll mention it in my archive).


Your solution unfortunatly don´t solve my problem with registry access. So I used the W2k DDK to build an "quiet" exe who do my installation, and start this exe from NSIS which also do a versionchecking of windows.


rio