Help me, O wise ones...
I've got a Perl script--converted from one in VBasic, that reads the registry and places its result into a variable passed in as an argument. The function's return is just 0 for success, anything else for failure. Is there *any* way to get my perlish paws on the result? Here's the code:
#!perl
# The following example reads and displays the value in the DWORD regi
+stry value
# HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CrashControl\Aut
+oReboot.
use Win32::OLE;
use constant HKEY_LOCAL_MACHINE => 0x80000002;
my $dwValue = 42;
$strComputer = '.';
$oReg = Win32::OLE->GetObject('winmgmts:{impersonationLevel=impersonat
+e}!\\\\' .
$strComputer .
'\\root\\default:StdRegProv');
$strKeyPath = 'SYSTEM\\CurrentControlSet\\Control\\CrashControl';
$strValueName = 'AutoReboot';
$oReg->GetDWORDValue(HKEY_LOCAL_MACHINE, $strKeyPath, $strValueName, $
+dwValue);
print 'AutoReboot' . ' == ' . $dwValue, "\n";
The output, as might be expected, is:
"AutoReboot == 42"
The vbs script, of course, works just fine, setting $dwValue to 1 (the current value on my PC). Thanks for any insight--especially one that shows the way...
Dismas
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.