afak
asked on
How do I modify a Register Key Permissions
I developed a windows (desktop) application using VB.NET 2003. The application has to be deployed in a network environment on windows XP or Vista. The first time that the application runs, it creates some register keys which have to be updated each the application is opened. At the installation time there is no problem with the keys because an administration account is being used. The problem comes when a regular user log in, runs the application and try to update the register keys. A popup denied modification permission appears. I need to set the permission on theses register keys to allow to normal or regular users modify and update the keys. Besides this procedure has to work for windows XP or Vista.
Thanks a lot for your response
Thanks a lot for your response
ASKER
I was trying your suggestion using RegistryPermissionAccess but it did not work. Maybe I am missing something. I am attaching the small function I created to try your method. I tried the write, and AllAccess but any of then work. After, I call this function I verify the register key using register editor (regedit) but the permissions in the users account don't change.
Thanks a lot for your help
Thanks a lot for your help
Public Function SetRegisterKey() As Boolean
Dim KeyPath As String = "HKEY_LOCAL_MACHINE\SOFTWARE\CGIclient\Data"
Dim RegPermission As RegistryPermission
Try
RegPermission = New RegistryPermission(RegistryPermissionAccess.AllAccess, KeyPath)
Catch ex As Exception
MsgBox("Exception Type: " & ex.GetType.FullName & vbCrLf & "Error: " & ex.Message, MsgBoxStyle.Critical, _
"Procedure: " & ex.TargetSite.GetCurrentMethod.Name)
Return False
End Try
Return True
End Function
Code.txt
Hmm, after a bit more research it turns out since the key was created under and admin account, the normal user wont be able to access it still using the .NET classes. I did find a shell script that can set what you need. I am thinking you can spawn it as a post install step or the first time the app is run by the user.
Example at:
https://www.experts-exchange.com/questions/24008482/Change-Registry-Permissions-of-a-specific-key-with-VB6.html
Definition of the integers at the end of the script
http://support.microsoft.com/kb/245031
Example of using ProcessStartInfo here
http://forums.devx.com/showthread.php?t=158388
Example at:
https://www.experts-exchange.com/questions/24008482/Change-Registry-Permissions-of-a-specific-key-with-VB6.html
Definition of the integers at the end of the script
http://support.microsoft.com/kb/245031
Example of using ProcessStartInfo here
http://forums.devx.com/showthread.php?t=158388
Save this line into a text file called RegIniSettings.txt
HKEY_LOCAL_MACHINE\SOFTWARE\CGIclient\Data [17 7]
Then run
regini C:\Path\To\File\RegIniSettings.txt
This will add SYSTEM as Full Control, and EVERYONE as Full Control
ASKER
I have tried regini.exe before, it works in windows XP but not in VISTA. One of the reason I became member experts-exchange was hopping to get a solution for Vista ans XP.
Thanks for your help!
Thanks for your help!
Really? regini is included with vista, so i assumed it would work without problems. I'll run a test on my machine in a bit to try it out. All I can think of is regini wouldnt work maybe from the application itself because it would be running as the user who doesnt have access already. I imagine the regini would have to be run during the install process (as the admin user) or perhaps you can combine the shell process using a runas command. I'll try regini on my machine in a bit and let you know how it goes.
I just tried the regini test on my Vista system. As a standard user I was not able to modify the permissions. When I logged in as the Administrator account, I was able to run and set the permissions using regini. As such is it possible to modify the installer to execute regini post install or is the existing install base to large for that to be feasible?
ASKER
As I mentioned in my original question, the keys are created the 1st time the application is running using the installer account (Administrator). Then, actually I was looking for a method to set the permissions at this moment, when the application run the first time, then, there is no problem when your suggestion.
What is rare for me is that I was doing some trials with regini using an administrator account on windows VISTA and didn't have success, I tried directly on the command line using cmd.exe. What version of VISTA do you try and what was the complete command you used?
I tried on Windows Vista Business to modify the permissions of the account USERS to full.
What do you did?
What is rare for me is that I was doing some trials with regini using an administrator account on windows VISTA and didn't have success, I tried directly on the command line using cmd.exe. What version of VISTA do you try and what was the complete command you used?
I tried on Windows Vista Business to modify the permissions of the account USERS to full.
What do you did?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window