Results 1 to 3 of 3

Thread: [RESOLVED] [2005] changing registry in vista

  1. #1

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Resolved [RESOLVED] [2005] changing registry in vista

    i've got a program i wrote in win xp that changes a registry value

    vb.net Code:
    1. Public regShell As RegistryKey
    2. Public regKey As RegistryKey = Registry.LocalMachine
    3.  
    4.  
    5. '' set startup options
    6. If RunToolStripMenuItem.Checked = False Then
    7.    RunToolStripMenuItem.Checked = True
    8.    regShell = regKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    9.    regShell.SetValue("screen capture", Application.ExecutablePath)
    10. Else
    11.    RunToolStripMenuItem.Checked = False
    12.    regShell = regKey.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
    13.    regShell.SetValue("screen capture", "<NonRun>")
    14. End If

    this worked well in win xp, but now i've upgraded to vista, it causes an error:

    'attempted to perform an unauthorised operation'

    how can i rewrite this so it doesn't cause this error?

    thanks

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] changing registry in vista

    The user running the application must have administrator privileges in order to make changes in the registry, thats why making changes in the registry is not a recommended practise.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [2005] changing registry in vista

    i googled it while i was waiting.
    you need administrator privileges to change Registry.LocalMachine but not for
    Registry.currentuser

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width