S
Shandyman
Hi --
I'm new to the area of interprocess communication, so I apologize if
this question seems rather elementary.
I'm interested in repeatedly opening and closing a Windows app (e.g.,
notepad.exe).
I put together the following script to try and do this:
#!/usr/bin/perl -w
#use warnings;
#use strict;
use Win32:rocess::Info;
use Win32;
my $program = "C:\\winnt\\system32\\notepad.exe";
system($program);
my $pi = Win32:rocess::Info->new ('localhost');
my @info = $pi->GetProcInfo ();
foreach my $process (@info) {
if( $$process{'Caption'} eq 'notepad.exe' ) {
kill 9, $$process{'ProcessId'} and exit;
}
}
What I'm finding is that, once the Windows program opens, I need to
close it manually before I can get to the portion of the script that
attempts to send the kill signal. I assume this is because Perl is
waiting for the Windows program to return, which never happens.
Is there something else I need to do to terminate the Windows program
automatically?
Any help you can provide would be greatly appreciated.
Thanks.
I'm new to the area of interprocess communication, so I apologize if
this question seems rather elementary.
I'm interested in repeatedly opening and closing a Windows app (e.g.,
notepad.exe).
I put together the following script to try and do this:
#!/usr/bin/perl -w
#use warnings;
#use strict;
use Win32:rocess::Info;
use Win32;
my $program = "C:\\winnt\\system32\\notepad.exe";
system($program);
my $pi = Win32:rocess::Info->new ('localhost');
my @info = $pi->GetProcInfo ();
foreach my $process (@info) {
if( $$process{'Caption'} eq 'notepad.exe' ) {
kill 9, $$process{'ProcessId'} and exit;
}
}
What I'm finding is that, once the Windows program opens, I need to
close it manually before I can get to the portion of the script that
attempts to send the kill signal. I assume this is because Perl is
waiting for the Windows program to return, which never happens.
Is there something else I need to do to terminate the Windows program
automatically?
Any help you can provide would be greatly appreciated.
Thanks.