0

Enviroment: windows 7

Currently i have machine on which we launch 2 batch files on system start up. These batch files internally run multiple programs by running on separate command prompt windows.

So in effect, i have lets say 3 command prompt windows open after the start up.

My requirement is that i want to close a specific command prompt window of the above 3.

How should I approach this? I cant close all the 3 instances of the command prompt windows. My thought is that if there is a way to identify these windows, I can use it to find it.

Schu
  • 123
  • 3
  • I think it would help if you could outline your initial problem that's caused you to think this might be a possible solution. – dbr Apr 13 '15 at 18:21

2 Answers2

1

Edit your parent batch file to use the "title" argument of the START command.
Each cmd window title bar will then contain that title, and you will know which is which, and be able to close that window.
The started item can be another batch file, or something like sales.exe, reports.exe, or migrate.exe

start "Red Widget" red.bat
start "Green Widget" green.bat
start "Blue Widget" blue.bat
Clayton
  • 4,523
  • 17
  • 24
0

The easiest way, if you are looking for a manual solution, is to use Microsoft's Process Explorer. This lets you easily view a given process, which process spawned it, when it was spawned, and also the full command line. It just lots more as well.

If you're looking for an automated way, use WMI and the Win32_Process class to gather the same information programmatically, e.g.:

WMIC PATH Win32_Process WHERE Name="cmd.exe" Get CreationDate, CommandLine, ProcessId, ParentProcessId
Simon Catlin
  • 5,232
  • 3
  • 17
  • 20