perllee has asked for the wisdom of the Perl Monks concerning the following question:
Implementation of the code,Erroe:use Win32; use Win32::OLE; #$machine= shift || Win32::NodeName(); my $machine="WH2851030605387"; #The office of another PC $class = "WinMgmts:{impersonationLevel=impersonate}!//$machine"; + $wmi = Win32::OLE->GetObject($class); $plist = $wmi->InstancesOf("Win32_Process"); $~ = PROC_LIST; write; $~ = PROC_INF; $n = 0; foreach $Proc (Win32::OLE::in( $plist )){ write; $n++; } print " ===========================\n"; print " -> Processes number : $n <-\n"; print " ==========================="; # -------------------------------------------------------------------- +--------- format PROC_LIST = @||| @|||||||||||||||| @||||||| "PID", "Process Name", " Memory" ---- ----------------- -------- . format PROC_INF = @<<< @<<<<<<<<<<<<<<<< @<<<<<<< $Proc->{'ProcessID'},$Proc->{'Name'}, $Proc->{'PeakWorkingSetSize'} .
C:\Documents and Settings\lisuzhong\Desktop>perl -w procList.txt
Win32::OLE(0.1707) error 0x800706ba: "RPC " after character 0 in "WinMgmts:{impersonationLevel=impersonate}!//WH2851030605387" at procList.txt line 8
eval {...} called at procList.txt line 8 Can't call method "InstancesOf" on an undefined value at procList.txt line 9. ------------------------------------------
Above,should be how do we solve this?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to generate a process list from a Remote XP Machine using Perl and WMI
by Anonymous Monk on Nov 26, 2008 at 07:51 UTC | |
|
Re: How to generate a process list from a Remote XP Machine using Perl and WMI
by pKai (Priest) on Nov 26, 2008 at 12:47 UTC | |
|
Re: How to generate a process list from a Remote XP Machine using Perl and WMI
by Bloodnok (Vicar) on Nov 26, 2008 at 12:11 UTC |