Computing.Net > Forums > Disk Operating System > Kill an application from a cmd line

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Kill an application from a cmd line

Reply to Message Icon

Name: lee
Date: June 14, 2001 at 07:57:43 Pacific
Comment:

I want to run a batch file to open and close an application at a certain time. I can get the app to open, but can't get it to close.

Thanks in advance.
Lee



Sponsored Link
Ads by Google

Response Number 1
Name: westwood1
Date: June 14, 2001 at 13:55:51 Pacific
Reply:

what command are u using to kill the app? send me your script if you want me to look at it.


0

Response Number 2
Name: DoOMsdAY
Date: June 14, 2001 at 17:31:06 Pacific
Reply:

Is this in real DOS or a Windows DOS box? If the latter, I wrote an application awhile back that takes the text caption for the window as its sole parameter and issues a close to that window (much the same as if someone had clicked the window's [x]). If you like, I could send you that file. Note that this will not work for some apps as I've seen with my minimal testing - I don't know why nor have the time to find out.


0

Response Number 3
Name: tsuji
Date: June 14, 2001 at 22:31:08 Pacific
Reply:

For the sake of info sharing, DoOMsdAY, maybe you can take a look on my response in win9x-forum :

http://computing.net/windows95/wwwboard/forum/78716.html

see if it adds something to your utility reserve. Thanks for your attention.


0

Response Number 4
Name: Lee
Date: June 15, 2001 at 01:26:34 Pacific
Reply:

Doomsday

It is a Windows 98 Dos box and yes the app would be worth trying. E-Mail address above.

tsuji
Thanks for the info on the utils. I will be looking for them in the 9xx forum.

Lee


0

Response Number 5
Name: DoOMsdAY
Date: June 15, 2001 at 05:14:08 Pacific
Reply:

tsuji: The version I wrote works by doing an EnumWindows() for the name you provided and checks the text for each window via GetWindowText(). If it finds the one you specified, it issues a SendMessage( WM_CLOSE ) to it. So unlike the Microsoft version, you don't have to use one util to get the process ID then another to kill it. Also, the WM_CLOSE is a friendly way of asking if an app will close. If they're getting a process ID, they're probably TerminateProcess()ing the application, which on the always unstable 9x machines is a bad idea. However, an application *can* ignore a WM_CLOSE if it so chooses, so that is why my app may or may not work. My original version used TerminateProcess() and then I quickly changed it.


0

Related Posts

See More



Response Number 6
Name: DoOMsdAY
Date: June 15, 2001 at 05:16:40 Pacific
Reply:

Oh, and Lee, I sent you the file. It is (accidentally so) named the same as the Microsoft one, kill.exe. I was naming it after the Linux version. :)


0

Response Number 7
Name: tsuji
Date: June 15, 2001 at 05:37:57 Pacific
Reply:

Hello DoOMsdAY, I would guess kill.exe from MS ResKit uses the same approach as yours. Only once compiled, it is hidden away from users.

In fact, Kill.exe does not need tlist.exe. Tlist.exe helps users to determine more certainly the process id so as to avoid killing the wrong thread! It can kill a process by its exact process id (a six?-digit id) at that time or by identifying the process via pattern (more descriptive name).


0

Response Number 8
Name: DoOMsdAY
Date: June 15, 2001 at 16:31:34 Pacific
Reply:

tsuji: Process IDs are bulky. You need something like Process Viewer to find them out, so I went for the easier approach, the window caption. I could easily do Process IDs as well if someone wanted of needed that. Or allow you to specify forced kill or kind close request. Things like that. With Process ID support, from the sound of things, I'd have the same functionality as the MS version.


0

Response Number 9
Name: Secret_Doom
Date: June 19, 2001 at 18:29:55 Pacific
Reply:

Hi there.
Hey Doomsday, I wanned to learn more about those commands you listed
(
GetWindowText()
EnumWindows()
)

From what language is that? Where should I type or put commands of that kind? Is that Java, VisualBasic or what (well, at least I know it isn't batch, is it?)
Where can I go to aquire more info?

Thanks in advance!!

-- Secret_Doom --

email: secret_doom@hotmail.com


0

Response Number 10
Name: DoOMsdAY
Date: June 19, 2001 at 19:44:19 Pacific
Reply:

Short answer, in case anyone else is reading this. They are Win32 API calls. They can be called from any language that has such access, the util I wrote was in Visual C++. I will e-mail you the long answer.


0

Response Number 11
Name: Alick!
Date: July 9, 2001 at 13:17:50 Pacific
Reply:

DoOMsdAY, does your command work in WindowsNT? Does it work in all Window flavors (95,98,NT,Me,2000)?


Would you please send me a copy too?

Thanks

Alick!


0

Response Number 12
Name: phalen
Date: August 3, 2001 at 13:16:58 Pacific
Reply:

The utility close on this page:

http://wwwthep.physik.uni-mainz.de/~frink/nt.html

will close a running app given the title bar text, and includes source in C.

I am looking for a modification to this program or a similar utility that takes the name from the tasklist as a parameter, to kill "hidden" programs.

Please email me if you can help, thanks


0

Response Number 13
Name: phalen
Date: August 3, 2001 at 13:45:41 Pacific
Reply:

I found this great program after posting my last message:

http://www.xmlsp.com/pview/prcview.htm

It worked perfectly to do what I needed! Woohoo!


0

Response Number 14
Name: Bill
Date: December 3, 2001 at 08:25:41 Pacific
Reply:

DoOMsdAY-

I found these calls to close most all open windows:

SendMessage(cur_window, WM_CLOSE, 0, 0);
SendMessage(cur_window, WM_DESTROY, 0, 0);
SendMessage(cur_window, WM_NCDESTROY, 0, 0);

If you call TerminateProcess can't you give it exit code, and that will allow the process to shutdown smoothly?

Thanks in advance...


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Kill an application from a cmd line

Customising a boot floppy to automate ghost image loading www.computing.net/answers/dos/customising-a-boot-floppy-to-automate-ghost-image-loading/5027.html

Network adapter information www.computing.net/answers/dos/network-adapter-information/12936.html

old 386 will not boot from A drive- please help-thanks www.computing.net/answers/dos/old-386-will-not-boot-from-a-drive-please-helpthanks/1109.html