Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Greetings,
I am writing a script to get a list of processes and
the owners of those processes running off win2k.
I get the process list through the WMI using win32:OLE
Where i run into problems is when i try to send a
reference to a string to the method GetOwner.
According to the WMI SDK, GetOwner takes two strings
by reference one which will get the domain name
and the other which will get the user name. The
method returns an int indicating the status of the call
I have tried sending arrays, scalars, references etc...
but it doesn't work. I even tryed sending references
to a local variant type using Win32::OLE::Variant.
if anyone has done this before, or knows how to send
these strings to the API, i would greatly appriciate
it. thanks in advance
use Win32::OLE('in'); use Win32::OLE::Variant qw(:DEFAULT nothing); $server = ""; $lobj = Win32::OLE->new('WbemScripting.SWbemLocator') or die "can't create locator:".Win32::OLE->LastError()."\n"; $lobj->{Security_}->{impersonationlevel}= 3 ; $sobj = $lobj->ConnectServer($server, 'root\cimv2') or die "can't create server object:".Win32::OLE->LastError()."\n"; $procschm = $sobj->Get('Win32_Process'); $username = new Win32::OLE::Variant(OLE::VT_BSTR, " " ); $domainname = new Win32::OLE::Variant(OLE::VT_BSTR, " " ); foreach $process (in $sobj->InstancesOf("Win32_Process")){ $i=0; #$user=\$username; #$domain=\$domainname; #$userref = \$user; #$domainref = \$domain; $process->GetOwner(\$username,\$domainname); print $process->{Name}." is pid #".$process->{ProcessID}." User Time " +.$process->{UserModeTime}."\n"; print "Owner \\\\$domainname\\ $username\n"; }

In reply to Sending strings to win32:process-GetOwner() object by enigmae

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-19 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found