For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > April 2005 > Win32::Process Kill Process in Windows ME









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Win32::Process Kill Process in Windows ME
Stefan Mueller

2005-04-13, 8:55 am

Hello,

I want to kill a Process in Windows ME, which I have started. I have
executed the following lines in XP and it works. I execute this in ME,
the process starts but it won't be killed.

Win32::Process::Create($ProcessObj,
"C:\\Program Files\\Internet
Explorer\\iexplorer.exe",
"iexplore temp.txt",
0,
NORMAL_PRIORITY_CLASS,
".")|| die ErrorReport();

$ProcessObj->Kill(1);

Is there a possibility to kill processes in Windows ME?

Thanks in advance.

Stefan
Sisyphus

2005-04-13, 8:55 am


"Stefan Mueller" <s1210197@yahoo.de> wrote in message
news:f35b4d73.0504122349.79560db0@posting.google.com...
> Hello,
>
> I want to kill a Process in Windows ME, which I have started. I have
> executed the following lines in XP and it works. I execute this in ME,
> the process starts but it won't be killed.
>


What actually happens ? Does the script hang .... or exit silently .... or
..... ?
Do you get any warnings or error messages ?

use warnings;

> Win32::Process::Create($ProcessObj,
> "C:\\Program Files\\Internet
> Explorer\\iexplorer.exe",
> "iexplore temp.txt",
> 0,
> NORMAL_PRIORITY_CLASS,
> ".")|| die ErrorReport();
>


Not sure. Maybe (untested):

my $exitcode;
my $pid = $ProcessObj->GetProcessID();
Win32::Process::KillProcess($pid, $exitcode);
# $exitcode is set to the exitcode of the process.

Cheers,
Rob

--
To reply by email send to optusnet.com.au instead of nomail.afraid.org


Stefan Mueller

2005-04-15, 8:55 am

Hello Rob,

Thank you for your answer.

"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in message news:<425ce4a5$0$29868$afc38c87@news.optusnet.com.au>...
> What actually happens ? Does the script hang .... or exit silently .... or
> .... ?
> Do you get any warnings or error messages ?


No, I get no error messages. The script doesn't hang, it exists like
the way on XP.

> use warnings;


no warnings

> Not sure. Maybe (untested):
>
> my $exitcode;
> my $pid = $ProcessObj->GetProcessID();
> Win32::Process::KillProcess($pid, $exitcode);
> # $exitcode is set to the exitcode of the process.


it's the same. What's about the exitcode? I have used 1 and 9, but
there is no difference.

Cheers,
Stefan
Sisyphus

2005-04-15, 8:56 pm


"Stefan Mueller" <s1210197@yahoo.de> wrote in message
news:f35b4d73.0504142300.553dc396@posting.google.com...
> Hello Rob,
>
> Thank you for your answer.
>
> "Sisyphus" <sisyphus1@nomail.afraid.org> wrote in message

news:<425ce4a5$0$29868$afc38c87@news.optusnet.com.au>...
or[color=darkred]
>
> No, I get no error messages. The script doesn't hang, it exists like
> the way on XP.
>


I can't find any documented reason for the problem (and I don't actually
have a Windows ME to experiment with). KillProcess() calls OpenProcess() and
TerminateProcess(). I've checked the msdn docs for both OpenProcess and
TerminateProcess and there's no mention of any special considerations
regarding Windows ME.

If you want (and assuming you can compile Win32::Process from source) you
could try changing (in Process.xs):
HANDLE ph = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
to:
HANDLE ph = OpenProcess(PROCESS_TERMINATE, 0, pid);

(You'll find that about 5 or 6 lines from the end of the file.) I can't
really think of any reason that should help, however.

ActiveState now hosts a (low volume) libwin32-perl mailing list. Maybe
someone there can help. See:
http://aspn.activestate.com/ASPN/Mail/

Cheers,
Rob






Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com