Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Kill a process
Message
From
08/12/2007 23:21:02
 
 
To
08/12/2007 22:27:13
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00890217
Message ID:
01274241
Views:
26
Hi Jay, keep in mind that you should not kill a process unless you cannot close it gracefully. What is the 2nd exe you are calling? Is there a way to pass to it to tell it to close itself? (See the code I gave you for some ideas)



>Hey Hugo, I've been reading through this thread because I need a way to kill a running EXE from within another EXE. I can't quite find where the solution is, even though this message was marked as such. Is there a full code block in here somewhere that shows how you do this? Also, it assumes I know the processID, but I'm not sure how to get that. Looking that up now, but wanted to get the message posted in case you are awake and bored... <g>
>
>>Selim, did you try my method and did not work? It should work in W2K and WXP
>>
>>Try replacing
>>
oShell.Run("TaskKill /PID " + ALLTRIM(STR(wlprocessid.ProcessId))
>>with
>>
KillProcess(wlprocessid.ProcessId)
>>
>>Doesn't this work? What is the error? It works fine for me.
>>
>>
>>
>>procedure KillProcess(tnProcessID)
>>
>>loCIMV2		= GetObject("winmgmts://localhost/root/cimv2")
>>loProcesses	= loCimv2.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = " + alltrim(str(tnProcessID)))
>>For Each objProcess in loProcesses
>>	objProcess.Terminate(0)
>>Next
>>return
>>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform