For starters, I've been using Win32::Registry for a long time. I know people use Win32::TieRegistry now, but I don't believe this to be the root of my problem.

I have some code that fails with "Access is denied" printed in the portions when I print out the Win32 error message. Here's the code I've tested (it works on NT4, so I think this problem is specific to 2000 and higher).
if ( $HKEY_CURRENT_USER->Create('Software\\Policies\\Microsoft\\Intern +et Explorer\\Restrictions', $IE6 ) ) { print "Created IE restrictions!\n"; if ( $IE6->SetValueEx("NoBrowserOptions", 0 , REG_DWORD, 1) ) { print "Disabled browser options\n"; } else { print "Browser options still enabled.\n"; print $^E,$/; } if ( $IE6->SetValueEx("NoBrowserBars", 0 , REG_DWORD, 1) ) { print "Disable changes to browser bars\n"; print $^E,$/; } else { print "Browser bars can be altered still\n"; print $^E,$/; } if ( $IE6->SetValueEx("NoFavorites" , 0 , REG_DWORD, 1) ) { print "Disabled favorites menu\n"; print $^E,$/; } else { print "Favorites menu still enabled\n"; print $^E,$/; } $IE6->Close() && print "Done here!\n"; } else { #print $^E,$/; if ( $HKEY_CURRENT_USER->Create('Software\\Policies\\Microsoft\\In +ternet Explorer', $IE7) ) { print "We have now enabled the restrictions.\n"; if ( $IE7->Create('Restrictions', $IE8) ) { print "Also good!\n"; if ( $IE8->SetValueEx("NoBrowserOptions", 0, R +EG_DWORD, 1) ) { print "Disabled browser options.\n"; } else { print "Browser options not disabled\n" +; print $^E,$/; } if ( $IE8->SetValueEx("NoBrowserBars", 0, REG_ +DWORD, 1) ) { print "Disable changes to browser bars +.\n"; } else { print "Browser bars still can be chang +ed\n"; print $^E,$/; } if ( $IE8->SetValueEx("NoFavorites", 0 , REG_D +WORD, 1) ) { print "Disabled favorites menu.\n"; } else { print "Favorites menu not disabled\n"; print $^E,$/; } $IE8->Close() && print "Restrictions set.\n"; } else { print "Restriction creation failed\n"; print $^E,$/; } $IE7->Close && print "Restriction setup complete.\n"; } else { print "Key creation failed\n"; print $^E,$/; } }

Basically, what this code does is disable some options in Internet Explorer. While I was writing this code, I noticed that the keys don't always exist by default, so they may need to be created. The Create method will do an Open if the key already exists, or create it and then open if it doesn't. I have some other code that modifies some values in the registry that works just fine (it's also in the same script), so there appears to be a problem with creating the key if it does not already exist.

I've been searching google, as well as hitting IRC for days now trying to figure out why I'm getting these errors. Since they code is working on HKEY_CURRENT_USER, there should be no restriction on what keys I can create or modify (since I can modify with no problem). Any help would be appreciated.

Edit: g0n - Added readmore tags

Theodore Charles III
Network Administrator
Los Angeles Senior High
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;"

In reply to Win32 registry wierdness by Necos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.