Reading from registry

T

Totto

Hi,
Is possible to read from HKEY_LOCAL_MACHINE whithout beeing loged in as
administrator or power user?
Have tried using the following code, but if loged in as User there is a
security matter.

Dim regKey As RegistryKey = Registry.LocalMachine
Dim strCheckTime As String
regKey = regKey.CreateSubKey(SubKeyOPCProgid)
strCheckTime = regKey.GetValue("CheckTime", strCheckTime)
If it's not possible to read from LocalMachine withourt beeing loged in as
Administrator or power user, where is the right place to store app settings
available to all users ?

Tnx
Totto
 
O

One Handed Man

Yes, you cannot mitigate Win32 security.

OHM
Hi,
Is possible to read from HKEY_LOCAL_MACHINE whithout beeing loged in
as administrator or power user?
Have tried using the following code, but if loged in as User there is
a security matter.

Dim regKey As RegistryKey = Registry.LocalMachine
Dim strCheckTime As String
regKey = regKey.CreateSubKey(SubKeyOPCProgid)
strCheckTime = regKey.GetValue("CheckTime", strCheckTime)
If it's not possible to read from LocalMachine withourt beeing loged
in as Administrator or power user, where is the right place to store
app settings available to all users ?

Tnx
Totto
 
J

Jay B. Harlow [MVP - Outlook]

Totto,
Note you are attempting to WRITE to the registry, not read it!

The Administrator would need to give each user access to specific keys under
HKEY_LOCAL_MACHINE using regedit.exe to allow them to read & write there. I
believe a setup program could also set the permission (possible with a
custom Installer class). I would recommend having the setup program create
the respective keys and set the respective permissions.

Alternatively you may be able to use
System.Windows.Forms.Application.CommonAppDataPath or
System.Windows.Form.Application.CommonAppDataRegistry to store settings for
your app shared by all users.

Hope this helps
Jay
 
T

Totto

Tanks Jay,
Big help

Jay B. Harlow said:
Totto,
Note you are attempting to WRITE to the registry, not read it!

The Administrator would need to give each user access to specific keys under
HKEY_LOCAL_MACHINE using regedit.exe to allow them to read & write there. I
believe a setup program could also set the permission (possible with a
custom Installer class). I would recommend having the setup program create
the respective keys and set the respective permissions.

Alternatively you may be able to use
System.Windows.Forms.Application.CommonAppDataPath or
System.Windows.Form.Application.CommonAppDataRegistry to store settings for
your app shared by all users.

Hope this helps
Jay
 
O

One Handed Man

It means that Win32 security will stop him doing this unless he has been
given explicit privilages to do so.

Regards
 
H

Herfried K. Wagner [MVP]

* "One Handed Man said:
It means that Win32 security will stop him doing this unless he has been
given explicit privilages to do so.

Thank you for the explanation!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top