Using Win32::OLE...
use Win32::OLE ('in'); ... @host = ($server,"Root/default",$user,$password); $localWMI = Win32::OLE->new('WbemScripting.SWbemLocator'); $WMI = $localWMI->ConnectServer(@host); $registry = $WMI->Get("StdRegProv") or die "Failed to get registry."; $strPath='SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName'; $strValue = "ComputerName"; print $strPath; $return=$registry->GetStringValue( 2147483650, $strPath, $strValue, $result ); print "\n$strValue:($return,$result)\n"; my $err = Win32::OLE->LastError(); if ($err == 0) {print "Successful!\n";} else {print $err;}
You think it would be in $result, don't you?
I always get...
ComputerName:(0,)
Successful!

So there is no OLE error... and according to other scripts I've seen, everybody expects the query to be put in that variable... If I change the path statements/reg key name, I get funky error codes (161, -2147217403, etc.), so I know it's READING the value right.... but where does it PUT the value???

edited: Thu Mar 27 14:20:32 2003 by jeffa - appended "(problem with Win32::OLE)" to title


In reply to Where's the result??? (problem with Win32::OLE) by jpavel

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.