How to check and close a program

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

How to check and close a program

Post by alemrantareq » Fri Nov 28, 2008 11:11 am

Hi everybody,
In Process tab of Windows Task Manager, we see the available programs that are running. Suppose I've a program "MyProg.exe" is running in process tab but not in applications tab of Windows Task Manager. I want to make a script for a btn to check whether that program is running or not and close if running. Can it be done by kill command? Please, help......

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Fri Nov 28, 2008 3:37 pm

You know, the 'kill' command should only be used as a last resort - as the process that is killed doesn't get a chance to cleanup whatever resources it is locking - and in turn any resources it is connected to may take some time to clear themselves.

So let's see if we can help prevent this situation from happening. What exactly are the circumstances?
- is this a Revolution application that you build yourself and which has become 'faceless' ?
--> see my reply to your previous question "Keep the app always active"
- or are you trying to find a way to stop an executable written by someone else ?

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Sat Nov 29, 2008 7:21 am

Hi Janschenkel,
Thanks for your reply. I just trying to find a way to stop an executable from the process tab. Your reply in "Keep the app always active" works nicely. Thanks again for that. Now pls, help me giving its sulotion...

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Tue Dec 02, 2008 6:56 am

I'm glad solving my own problem. The "shell" function can be used to kill/close a program from the process tab of windows task manager. For example, in windows XP, a program "MyProg.exe" is running in process tab. To kill that program, the following script can be applied to a button -

Code: Select all

on mouseUp
set the hideconsolewindows to true
get shell("taskkill /f /im MyProg.exe")
end mouseUp
Caution: the "taskkill" command is applicable only for windows xp, for the other versions of windows, the command may be different.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Dec 02, 2008 11:57 am

Thanks, Mark Stuart.

Best,

Mark Sch
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Tue Dec 02, 2008 4:07 pm

Tareq, it seems a good many of your posts here are also submitted to the use-rev list, but when answers are provided there you do not see them.

Is there perhaps an issue with your mail filters preventing you from getting the many timely and helpful replies people have been posting for you on the use-rev list?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply