I am trying to get process information for my windows machine, but one of the processes is returning a null value for the ExecutablePath. However, through Process Explorer I can see the Path, but I'm unsure if PE is getting this information another way. The code works for other processes. My code is below:
use Win32::OLE; my $objWMIService; unless ($objWMIService = Win32::OLE->GetObject("winmgmts:{impersonatio +nLevel=impersonate}!\\\\.\\root\\cimv2")) { print("Could not connect to WMI Service on localhost while attempt +ing to collect a remote item. The error returned was: " . Win32::OLE +->LastError() . "."); } my $colItems; unless($colItems= $objWMIService->ExecQuery("SELECT * FROM Win32_Proce +ss", "WQL",0x10 | 0x20)) #unless($colItems= $objWMIService->ExecQuery("SELECT * FROM Win32_Proc +ess")) { print("Could not extract notification query from WMI Service on lo +calhost . The error returned was: " . Win32::OLE->LastError() . "."); } foreach my $objItem (in $colItems) { if(defined($objItem->{CommandLine}) && ($objItem->{CommandLine} = +~ /^.*[Ss][Mm][Ss][Ss]\.[Ee][Xx][Ee]$/)) { print "#################################################\n"; print "CommandLine: '" . $objItem->{CommandLine} . "'.\n"; print "ExecutablePath: '" . $objItem->{ExecutablePath} . "'.\n +"; print "Name: '" . $objItem->{Name} . "'.\n"; print "Caption: '" . $objItem->{Caption} . "'.\n"; print "#################################################\n"; } }
Output:
perl process.pl ################################################# CommandLine: '\SystemRoot\System32\smss.exe'. ExecutablePath: ''. Name: 'smss.exe'. Caption: 'smss.exe'. #################################################
I expect to see 'ExecutablePath: C:\Windows\System32\smss.exe'. Any help would be greatly appreciated.
In reply to Windows Process Executable Path is Null by dt667
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |