473,769 Members | 2,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to terminate a process on win32?

Hi,

I am developing two app on Windows, one is a GUI using wxPython and the other is like a daemon process. The GUI app will have a start/stop button to control the excution of the daemon. While I know how to use os.popen2() to start my daemon, I can't figure out a way to stop it 'nicely'... Is there anything that I can do?

Regards,

-- Wong

Jul 18 '05 #1
4 2394
Joe Wong wrote:
Hi,

I am developing two app on Windows, one is a GUI using wxPython and the
other is like a daemon process. The GUI app will have a start/stop
button to control the excution of the daemon. While I know how to use
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?

Regards,

-- Wong


You can use the win32process.Te rminateProcess function to kill a
process... see the win32 docs

David
Jul 18 '05 #2
"Joe Wong" <jo*****@mango. cc> wrote:
I am developing two app on Windows, one is a GUI using wxPython and the
other is like a daemon process. The GUI app will have a start/stop
button to control the excution of the daemon. While I know how to use
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?


It depends on your OS. I remember once upon a time, in order to kill
processes sucessfully for all Windows platforms (from Win98 to NT to
2000/XP), I had to resort to using tlist.exe and kill.exe, plus
w9xpopen.exe for pipes in Windows 98. It was kind of annoying... I
seem to remember short name and long names were problem, too. At the
end, the killing logic became a small program in itself!

regards,

Hung Jung
Jul 18 '05 #3
"Joe Wong" <jo*****@mango. cc> wrote in message news:<ma******* *************** *************** @python.org>...
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?


Mark Hammond's Python for Windows extensions includes a demonstration
of killing processes on Windows:

On my PC:
C:\Python23\Lib \site-packages\win32\ scripts\killPro cName.py

Python for Windows extensions:
http://starship.python.net/crew/mhammond/
https://sourceforge.net/projects/pywin32/

Regards, Myles.
Jul 18 '05 #4
But calling TerminateProces s will stop the application right away. I need
someway that the process being killed get notified and thus to carry out
some procedure before shut down. On Linux, I can use kill(pid, signum) to
achive this but on windows?
----- Original Message -----
From: "Myles" <my***@geocitie s.com>
Newsgroups: comp.lang.pytho n
To: <py*********@py thon.org>
Sent: Wednesday, May 26, 2004 9:49 AM
Subject: Re: how to terminate a process on win32?

"Joe Wong" <jo*****@mango. cc> wrote in message news:<mailman.1 64.1085188722.6 949.py********* @python.org>...
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?


Mark Hammond's Python for Windows extensions includes a demonstration
of killing processes on Windows:

On my PC:
C:\Python23\Lib \site-packages\win32\ scripts\killPro cName.py

Python for Windows extensions:
http://starship.python.net/crew/mhammond/
https://sourceforge.net/projects/pywin32/

Regards, Myles.
--
http://mail.python.org/mailman/listinfo/python-list

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
21032
by: deko | last post by:
I use the default windows phone dialer to make calls from an Access form. I close the phone dialer after the call is made using the below function. The problem is I'm not closing the Phone Dialer application properly which results in the Phone Dialer icon remaining in the system tray. I've tried using the Windows API to refresh the system tray, but could not get that to work. How to I gracefully close the phone dialer application with...
7
5758
by: Andrew S. Giles | last post by:
Hello, I am looking for an article, or some information about how to get a C# windows forms application to trap the "End Process" event from the Task Manager? Is such a thing possible, and if so, where is the information on the event the would be raised located in the .NET framework? Thanks in advance for your help and information.
3
13786
by: Keith Grefski | last post by:
I cant seem to figure out how to terminate a process in vb.net i can do it using vbscript and wmi but terminate doesnt seem to exist in the available classes for wmi under vb.net
3
5923
by: Peter Neuburger via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Peter Neuburger Hi Everybody, I need some help with the WMI Terminate Method. I have a Listbox where I get all the Process Information using the WMI Win32_process
1
2036
by: kk5151 | last post by:
Hi, Do you know any simple script to terminate the iexplorer.exe. On window, I have to go to Task Manager -> processes -> End process of "IExplorer.exe". Currently I have 30 IE browsers running on the PC, and would like to know any simple script to terminate this process. Thanks,
2
2505
by: cnsabar | last post by:
Hi., I am using the following code to terminate the any process by giving the process name as input... use Win32::Process::List; use Win32::OLE; $Win32::OLE::Warn = 3; $P = Win32::Process::List->new(); print "Enter the process name.exe to terminate: ";
0
1692
by: cnsabar | last post by:
Hi., I need a Perl script to terminate the any running process in server. by specifying computer name and process name.. I have the following code to terminate the any process by specifying the process name in the local system... use Win32::Process::List; use Win32::OLE;
1
2461
by: thunder54007 | last post by:
hi, here is my script: import win32con import time import wmi c = wmi.WMI() for process in c.Win32_Process(name = "notepad.exe"): print process.ProcessId, process.Name process.Terminate ()
2
3968
by: Smokey Grindel | last post by:
Is there anyway to check if an external process is running, then terminate it if it is? my problem right now is in my installer the user might try to upgrade while the program is running... I want to check if it is running, notify them it is, then ask them if they want to terminate it or not... thanks!
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.