By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,595 Members | 1,433 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,595 IT Pros & Developers. It's quick & easy.

terminating an inactive process

P: n/a
I'm running a PyWin program that executes another program using
subprocess.Popen(). Unfortunately, this other program isn't well
behaved, and frequently terminates without terminating its process.
After this happens enough times, all my memory is tied up, and the
machine crashes.

Using subprocess.poll(), I can keep my program from hanging, by timing
out the process, and starting anew. This still leaves the previous
process hogging memory. How do I kill the old process in Windows?

Earl

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
i use this to open/close netscape as it also doesnt like to close all
the time. its a WMI script but easiely edited.

check out script-o-matic from ms-downloads , it outputs python code as
well as others.
################################################## ####################
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_Process",,48)
For Each objItem in colItems
strProcess = Ucase(objItem.Name)
If strProcess = "NETSCP.EXE" Then
objItem.Terminate()
End If
Next
'---------------------
MyVar = MsgBox ("Do you want to start Netscape Mail and News " &
chr(13) & chr(13) & "Any Zombie processes have been exorcised from the
machine already." & chr(13) & chr(13) , 308, "Warning!")
Set objWMIService = Nothing
Set colItems = Nothing
If MyVar = 7 Then
Wscript.Quit
Else
sExecStr = "C:\Program Files\Netscape\Netscape\Netscp.exe -mail"
Dim oShell, obj
Set oShell = WScript.CreateObject ("WSCript.shell")
Set obj = oShell.exec(sExecStr)
Set oShell = Nothing
Set obj = Nothing
End If

'--------------------------------
MyVar = MsgBox ("Click to close Netscape")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_Process",,48)
For Each objItem in colItems
strProcess = Ucase(objItem.Name)
If strProcess = "NETSCP.EXE" Then
objItem.Terminate()
End If
Next
Set objWMIService = Nothing
Set colItems = Nothing

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.