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)