Registry: Editing values...VB.Net WinApp/WebApp ..Security

G

Guest

Getting real tired of this...

After several attempts on this forum, and implementing proposed solutions,
to write to the registry...Still a month down the line, having migrated from
WebApp (IIS security settings and associated ...)
to Windows App... to escape the IIS security settings etc.
I still have no resolution.

Every Key and subkey in my registry in my read/write path has every known
permission and advanced setting set to FullControl , nothing denied.
You name it, its there .....!!

Gave up on Web App approach.. VB.Net WebApplication...no joy, now the same
scenario with Windows Application
Frustrated (....very !! )


Reading a value ..NO PROBLEM
Writing a Value....NO WAY !!!!!! ''Error: cannot write to the
registry key"

Is there anybody who can actually provide me with a working solution...??

Beneath the code I use.

TIA

'checks to see read functionality
key = Registry.CurrentUser.OpenSubKey("SOFTWARE\SPLUS\pwd")
key.GetValue("pwd")

Dim f As New
RegistryPermission(RegistryPermissionAccess.AllAccess, _
"HKEY_CURRENT_USER\SOFTWARE")
f.AddPathList(RegistryPermissionAccess.Write,
"HKEY_CURRENT_USER\SOFTWARE")
f.AddPathList(RegistryPermissionAccess.Write,
"HKEY_CURRENT_USER\SOFTWARE\SPLUS")
f.AddPathList(RegistryPermissionAccess.Write,
"HKEY_CURRENT_USER\SOFTWARE\SPLUS\pwd")

f.Assert()

key.SetValue("pwd", sValIn) 'cannot write to the registry key
 
G

Guest

So..???
I don't follow what you propose as a solution , if any at all... in fact I
don't understand what you are saying.

and when trying to write from a Windows Application.... then it's not under
the auspices of IIS, yet I have the same problem.??
 
G

Grant_Aust

Neal, here is some code I am using to add my applications to the Run key in
the registry. Hope this gives you an idea.

Public Sub ToggleAutoRun(ByVal ExecutableNameIncludingExe As String, ByVal
KeyName As String, ByVal StateToSet As Boolean)
Try
'Add the application to the Run key on the local machine.
'Fist define some variables for this subroutine...

Dim regRunKey As Microsoft.Win32.RegistryKey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey
("Software\\Microsoft\\Windows\\CurrentVersion\\Run", True)
Dim valueNames() As String
Dim valueExists As Boolean = False
Dim i As Integer

'Check for HKLM\Software\Microsoft\Windows\CurrentVersion\Run\'KeyName'
key...
valueNames = regRunKey.GetValueNames
For i = 0 To valueNames.GetUpperBound(0)
If valueNames(i) = KeyName Then valueExists = True
Next

'Set the registry key wrt the passed value 'StateToSet'...
If StateToSet = True Then
regRunKey.SetValue(KeyName, ExecutableNameIncludingExe)
Else
If valueExists = True Then regRunKey.DeleteValue(KeyName)
End If

Catch ex As Exception
CatchErrors(ex)
End Try

End Sub
 

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