Results 1 to 8 of 8

Thread: Having trouble with a registry read

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    11

    Having trouble with a registry read

    I have a program that reads a value in the registry. When I "Debug" it, it works. When I build and run the EXE I get a Security Error.

    Is there something I need to do in the program that allows registry reads?

    Here is my code:

    key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\SNAP Systems, Inc\WinSNAP\DefaultSite")
    DefaultSite = CType(key.GetValue(""), String)

    EDIT:
    Exact Error>
    Request for the permission of type
    System.Security.Permissions.RegistryPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.


    Thank you
    Ron.
    PS: I'm not sure (because I'm a NOOBIE) if there is anything else you'll need to know. Please ask and I'll provide.
    Last edited by Capt_Ron; Jun 1st, 2004 at 01:43 PM.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    What type of logon authority do you have? Are you logged in as an administrator, or a regular user?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    11
    I'm a domain admin.

    I guess that is the problem. Any ideas around it?

    Is there a way to read the registry without opening it? Or does Windows assume that any interaction with the registry is bad and therefore a regular User can't access it?

    Ron.

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Actually, a domain admin should have no permission issues. That's a wierd one.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    11
    Maybe I was unclear. I do that sometimes

    I have no problems running this. The regular Users do.

    Ron.

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    I think that regular users have access to the HKEY_CURRENT_USER registry key at the very most, but they might not even have that.

    Is this a key you have created, or is it defined by another app?

    If its yours, you might want to look into using xml or something else that is a little less locked down.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    11
    It's created by another App.

    Here's a thought. Is there a way to get Computer Name?

    The value I'm trying to get is a 4 digit number. That number is also part of their computer name.

    Could I get and parse the computer name and use that instead?

    hmmm.....

    This could get interesting...

    Ron.

    PS: I really appreciate your help!!!!

  8. #8

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    11
    I Got It!!! I Got It!!!

    I'm sooooo smart.... Or at least the author of the book is and I just happened to find it. hehe.

    I'll use the Computername Environment variable and parse it.
    I found the code in VB.NET Cookbook (MS press). Good book.
    I also found a nice variable called TMP which is the Temp directory path for the current user. I get to use that too!

    Now this is making an assumption that certain environment variables are still available in XP Pro.


    I really appreciate your help. Didn't get a registry solution, but led me to a better one!!

    Man! I love forums!!

    Capt Ron.

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