For more advanced batch scripts, you may want to run a cmd.exe instance in the background. However, it can be hard to tell if it is running or not once you’ve launched it. CMDs allows you to see open windows in the foreground and background as well as find the PID of any cmd.exe window based on its title.
Not only can users do this from a simple (and colorful) text-based GUI, developers can also use it’s simple, built in commands designed for batch coders!
CMDS is a pretty simple tool to use. Here’s the help documentation:
CMDS Command Prompt Window Lister by IT Command
CMDS [/S] [/P] [/L] [/W] [/V] [/Ver] [/G Num] [/K Num] [/TK String] [/TS String]
/S Displays the simple but high information version (fast)
/P Pauses Before Exiting. Usefull if using from Run.
/L Pauses and refreshes on press of key. Use CTRL+C to quit.
/W Refreshes only when a new cmd instance starts (new PID).
/G For use when listing entries. Copies an entry from a
displayed list to clipboard.
/K For use when listing entries. Kills an entry from
displayed list.
Note: /G and /K will pull numbers and PIDs from the previous CMDS
list through a variable to increase accuracy.
Num The number of the entry to copy to clipboard or kill.
/V Ignores unnamed windows.
/Ver Prints the current version of CMDS and allows you to check
for an update. /version may also be used.
/TS Use within a batch file to search for a Window Title.
/TK Use within a batch file to kill a matching Window Title.
String The Window Title to search for with /TS or /TK
with /TS the errorlevel will be set to 1 if the title was not found.
If it is found, the errorlevel will be set to the PID of the cmd instance.
Example:
CMDS /TS "My Window"
The Above Command Will set the errorlevel to the PID of the cmd instance
with the title "My Window" (set with the title command). If the instance
is not found (there is no running window) the errorlevel will be 1.
if the Syntax was incorrect, errorlevel will be set to 2.
Created by Lucas Elliott with IT Command www.itcommand.net
There’s a few things to check out here. First, the basic functionality of CMDS allows you to view what windows are open. On my machine, running CMDS outputs the following:
As you can see, CMDS neatly displays the titles, memory usage, and pids of all of the open CMD windows, including ones launched in the background. It also shows windows with no unique title, including the one that is currently running CMDS (see the bottom two), although these can be ignored by adding /v
to the CMDS command.
Users can also use CMDS /w
which will refresh whenever a CMD window is opened or closed in order to display an up-to-date list at all times.
However, CMDS’ more advanced functionality is in its /TS
functionality. In the example above, there is a batch file running called “Crafty Controller”. Let’s say you knew that was running and wanted to kill the process from another batch file. With CMDS this is easy. Take this command for example:
CALL CMDS /TS "Crafty Controller"
If you ran this command, it would not provide any output on screen. Instead, the errorlevel will now be set to the PID of the Crafty Controller window!
What if you weren’t sure it was running? Well, if CMDS doesn’t find an instance running with the given title, it sets the errorlevel to 1. Pretty easy!
taskkill /f /pid %errorlevel%
However, in this example it gets easier. CMDS now has a built in feature to kill tasks:
CALL CMDS /TK "Crafty Controller"
You can also kill tasks from a cmds list and copy task PID’s from the numbered list in CMDS.
cmds /k 1
CMDS /G 3
How easy is that? Obviously this is a powerful tool for batch developers. It’s written 100% in batch with no executables or dependencies. The code is, of course, open source and under the GNU public license.
CMDS Version 23
CMDS Version 23 adds severe stability overhauls and adds a versioning system.
Check the readme for more information.
This version also adds optional installers. All the installers do is drop CMDS.exe into the system32 folder.
Note: If you wish to use CMDS.bat with your tool or program, it is recommended that you package CMDS.bat with the program and call it directly instead of making the user install it manually. This also will allow you to control which version of CMDS your program comes with.
- CMDS.bat 15.18 KB 55 downloads
- CMDS.Installer-v23.32Bit.exe 1.11 MB 26 downloads
- CMDS.Installer-v23.64Bit.exe 1.11 MB 58 downloads
- Source code
150 recent downloads.