ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
Re: killing a process by window title; was: socket application
by Thomas R Wyant_III other posts by this author
Jan 29 2003 2:52AM messages near this date
view in the new Beta List Site
RE: Win32-GUI - Manage Window Objects...? | Re: killing a process by window title; was: socket application
"Dirk Bremer \(NISC\)" <dirk.bremer@[...].cc>  wrote:

>  From: "Jonathan Epstein" <Jonathan_Epstein@[...].gov>

>  > This seems like a useful starting point, courtesy of Dave Roth:
>  >   http://www.roth.net/perl/scripts/scripts.asp?ProcList.pl
>  >
>  > In Python, I sometimes use one of the distribution scripts called
>  > killProcName.py.  Here's an excerpt which can probably be translated to
>  > Perl without too much difficulty:
> 
>  >                 handle = win32api.OpenProcess(
>  >                     win32con.PROCESS_TERMINATE,0,pids[0])
>  >                 win32api.TerminateProcess(handle,0)
>  >                 win32api.CloseHandle(handle)
>  >
>  >
>  > I believe that it should be possible to synthesize these two pieces
>  > of information and produce a solution.

>  All right, I'll admit it , I don't know zip about the Win32 API or OLE.
This
>  is all-new territory for me. I think the Dave Roth script example will be
>  useful in identifying the processes, but I still need a methodology to
kill
>  them. Anyone want to take a stab at translating the Python to Perl?

Well, since Win32::Process comes with ActivePerl, you _could_ go with

use Win32::Process;
my $handle;
Win32::Process::OpenProcess ($handle, $pids[0], 0);
$handle-> Kill (0);
__END__

which looks to me like the Perl equivalent of what the Python is doing. But
since this is Perl, There's More Than One Way To Do It, and I would
probably go with

kill KILL =>  @pids;
__END__


Of course, all the above seem to require the script to be on the same
machine as the process you're trying to kill, and none will work without
the proper privilege level.

Now, getting the window title I don't know about. I was about to suggest
Win32::Console::Title, but that, I believe, is only the command window (if
any) that is running the current script.

Anyone?

Tom Wyant



This communication is for use by the intended recipient and contains 
information that may be privileged, confidential or copyrighted under
applicable law.  If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited.  Please notify the sender
by return e-mail and delete this e-mail from your system.  Unless
explicitly and conspicuously designated as "E-Contract Intended",
this e-mail does not constitute a contract offer, a contract amendment,
or an acceptance of a contract offer.  This e-mail does not constitute
a consent to the use of sender's contact information for direct marketing
purposes or for transfers of data to third parties.

 Francais Deutsch Italiano  Espanol  Portugues  Japanese  Chinese  Korean

            http://www.DuPont.com/corp/email_disclaimer.html


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Thomas R Wyant_III

Dirk Bremer (NISC)

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved