This brings up a huge
pet peeve of mine which we should all try to remember as we’re
coding: Error messages should be required. And not just any error
messages, but RELEVANT error messages. This whole issue could have been
resolved much quicker with a simple “Access Denied”, but since the
return value was ambiguous, we weren’t able to narrow the scope of our
search as we attempted to find the problem. This is hardly the most egregious
case, but it’s a reminder to always think about what your program will do
if any given step fails. I remember a
particular time where I had to go back and review someone else’s code
because a script that production depended on was failing silently (old job, not
this one). I was beating my head against the wall until I finally
realized that one of the folders it was trying to copy a file to wasn’t
there. Adding the folder back “fixed the glitch”, but five
seconds of the programmer’s time would have saved me about three
hours. (It actually was worse than it sounds, the part in question that
was failing was not the script I was called in to look at, but a small program
written in C that nobody had the source to. But I digress…) *steps down from soap box* There. I feel
much better. From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Ng, Bill Whoops ... forgot the "$"
on "Registry".
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ng, Bill Yeah, It's a permission
thing with the registry ... I ran across it a few months back and posted to
this list. In the end I found the fix myself. Try this code
instead: ----------------- my $reg_key =
Registry->Open("HKEY_LOCAL_MACHINE\\Software\\ActiveState\\",
{Access=>1}); or $error = "ERROR: Can't
access registry key because, $^E\n"; print "error was
\"$error\"\n"; ----------------- Specifying the
Access level is the key. By the way Access=>1 only gives you read
access to that key. Bill From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Castle, Eric Hi, In preparation for the Vista OS
release, I am testing out how our perl scripts work when running as a
standard user on Windows XP SP2. This user has no power user or admin
permissions. So far when I try to access the
registry ( using Win32::TieRegistry) I get an error - the same error that I
would get if the registry key did not exist. I tried using perl 5.6.1 and 5.8
and it behaves the same in both. If running the same script as a
user with power user or admin priveldges, the scripts work fine and have no
problems accessing the registry. Other (non-perl) applications
running as std user are able to access the registry just fine (don't know if
they can alter it but they can at least read it). The registry key I was accessing was
HKEY_LOCAL_MACHINE\Software\ActiveState\ The error message I get back in $^E
is: "The system could not find the environment option that was
entered". Here is a sample script I used to test out the
problem: use Win32::TieRegistry; my $error = ""; my $reg_key =
$Registry->{"HKEY_LOCAL_MACHINE\\Software\\ActiveState\\"} print "error was
\"$error\"\n"; Has anyone else run into this?
I'm gonna do a search through MSDN also and see this has come up. Thanks, Eric |
_______________________________________________ Perl-Win32-Admin mailing list Perl-Win32-Admin@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs