Hi all,
this is in continuation with my last thread 'End a process in the Task manager'. Thnks all for very usefull suggestions. Now I am trying to get the PID of an excel file which I open through my script.
use Win32; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); use Win32::OLE; use Win32::OLE::Const; $Win32::OLE::Warn = 3; # die on errors... $curr_time = time(); print $curr_time; print "\n"; eval{ $Constant = Win32::OLE::Const->Load('Microsoft Excel'); $Excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) || die "Error launching MS Excel ".Win32::OLE->LastError(1); $Excel->{Visible} = 0; die "You must provide the filename with path\n" unless @ARGV; $Book = $Excel->Workbooks->Open($ARGV[0]); use Win32::API; Win32::API->Import("kernel32", "int GetCurrentProcessId()"); $PID = GetCurrentProcessId(); print "\n\n $PID \n\n"; ...... ...
but this gives me PID of 'perl.exe'. I tried to find the child processes of perl. But the excel file which is opened by perl is not a child of perl.exe but it is a child of 'svchost.exe'.
If this is the case how do I get the PID of the particular excel file which is opened by current process(perl.exe)

In reply to Get PID of an excel.exe opened by perl by Nalina

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.