Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Change registry key in Vista

Change registry key in Vista

Scheduled Pinned Locked Moved C#
helpcsharpwindows-adminsecurityquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarabjs
    wrote on last edited by
    #1

    Hi, We have a number of computers (>300), for which we need to change a particular registry setting. So I wrote a C# program that uses this code to do that: RegistryKey regkey = Registry.LocalMachine.OpenSubKey(KeyName, true); regkey.SetValue(KeyValue, 2); When I distribute the executable, it works perfectly for all XP machines. But the Vista machines (even while in user accounts with Admin access) throw an error: System.Security.SecurityException: Requested registry access is not allowed I've tried looking for solutions online but couldn't follow any. Anyone who can help me change a registry key value in Vista through C# code? Thanks, Sarab

    G D 2 Replies Last reply
    0
    • S sarabjs

      Hi, We have a number of computers (>300), for which we need to change a particular registry setting. So I wrote a C# program that uses this code to do that: RegistryKey regkey = Registry.LocalMachine.OpenSubKey(KeyName, true); regkey.SetValue(KeyValue, 2); When I distribute the executable, it works perfectly for all XP machines. But the Vista machines (even while in user accounts with Admin access) throw an error: System.Security.SecurityException: Requested registry access is not allowed I've tried looking for solutions online but couldn't follow any. Anyone who can help me change a registry key value in Vista through C# code? Thanks, Sarab

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      To run it on Vista, right click on the application and select "Run as administrator".

      Despite everything, the person most likely to be fooling you next is yourself.

      modified on Friday, September 26, 2008 9:51 AM

      1 Reply Last reply
      0
      • S sarabjs

        Hi, We have a number of computers (>300), for which we need to change a particular registry setting. So I wrote a C# program that uses this code to do that: RegistryKey regkey = Registry.LocalMachine.OpenSubKey(KeyName, true); regkey.SetValue(KeyValue, 2); When I distribute the executable, it works perfectly for all XP machines. But the Vista machines (even while in user accounts with Admin access) throw an error: System.Security.SecurityException: Requested registry access is not allowed I've tried looking for solutions online but couldn't follow any. Anyone who can help me change a registry key value in Vista through C# code? Thanks, Sarab

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        In addition to what Guffa said, these may help. Look at the System.Security.Permissions.RegistryPermission class and/or Add an app.manifest file and alter the requestedExecutionLevel - this will invoke UAC.

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups