943,657 Members | Top Members by Rank

Ad:
Jun 20th, 2008
0

Need to send Cntrl +C to an Running Exe using a DOS batch File.

Expand Post »
Hello,

I have a query regarding a DOS command. I know this link is not the right place to ask queres about DOS but didnt find any another link in this forum.

I need to send Cntrol +C to a running Exe (running on Windows) using a batch file.Can Any one guide me for this.

Regards.
Last edited by Ancient Dragon; Jun 20th, 2008 at 8:21 am. Reason: deleted inappropriate use of code tags
Reputation Points: 10
Solved Threads: 0
Light Poster
programmer321 is offline Offline
26 posts
since Aug 2007
Jun 20th, 2008
0

Re: Need to send Cntrl +C to an Running Exe using a DOS batch File.

>>Can Any one guide me for this.
As a batch file, forget it. Can't be done. There is no way to send anything to an already running program from a batch file. But you can write a C or C++ program to do that and call that program from the batch file.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,949 posts
since Aug 2005
Jun 24th, 2008
0

Re: Need to send Cntrl +C to an Running Exe using a DOS batch File.

But this thing is definitely possible in Linux.
Last edited by Ancient Dragon; Jun 24th, 2008 at 8:35 am. Reason: removed mis-used code tags
Reputation Points: 10
Solved Threads: 0
Light Poster
programmer321 is offline Offline
26 posts
since Aug 2007
Jun 24th, 2008
0

Re: Need to send Cntrl +C to an Running Exe using a DOS batch File.

Shell programming in *nix is considerably more powerful than batch processing in MS-DOS and MS-Windows. Most things you see in *nix shell programs are not possible in batch files.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,949 posts
since Aug 2005
Jul 3rd, 2008
0

Re: Need to send Cntrl +C to an Running Exe using a DOS batch File.

Ancient Dragon is correct, there is no way of manipulating threads using batch - or in other words, there is no command redirection available under command.com which allows you to send command output from a control-c into the input thread of a running program. You would have to use a programming language with a WIndows API available so you can manipulate threads via the Kernel.
Reputation Points: 13
Solved Threads: 9
Junior Poster in Training
omrsafetyo is offline Offline
58 posts
since Apr 2008
Sep 3rd, 2008
0

Re: Need to send Cntrl +C to an Running Exe using a DOS batch File.

All the other posters are correct from what I can tell. If you want to access a thread of a process your out of luck unless you bust out some C/C++ code to terminate it. If you just want to kill the running process then you can try to use pskill.exe provided in the Systernals Tools. Here is the help from the tool:

Quote ...
PsKill v1.12 - Terminates processes on local or remote systems
Copyright (C) 1999-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

Usage: pskill [-t] [\\computer [-u username [-p password]]] <process ID | name>
-t Kill the process and its descendants.
-u Specifies optional user name for login to
remote computer.
-p Specifies optional password for user name. If you omit this
you will be prompted to enter a hidden password.
Not necessarily a Ctrl+C, but it is a way to stop a process that is not owned/created by the batch file. Of course, if you are trying to send a SIGINT or SIGHUP you won't get the expected results using the above method.
Last edited by mittelgeek; Sep 3rd, 2008 at 9:21 am. Reason: Spelling errors
Reputation Points: 10
Solved Threads: 0
Light Poster
mittelgeek is offline Offline
37 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: Echo >> problem
Next Thread in Legacy and Other Languages Forum Timeline: help with .bat file opening multiple programs





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC