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

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.