{"id":25,"date":"2021-12-06T15:30:13","date_gmt":"2021-12-06T15:30:13","guid":{"rendered":"https:\/\/programs.lucas-elliott.com\/?p=25"},"modified":"2021-12-06T16:41:27","modified_gmt":"2021-12-06T16:41:27","slug":"cmds-view-and-manage-cmd-exe-windows-by-their-titles","status":"publish","type":"post","link":"https:\/\/programs.lucas-elliott.com\/index.php\/2021\/12\/06\/cmds-view-and-manage-cmd-exe-windows-by-their-titles\/","title":{"rendered":"CMDS &#8211; View and Manage CMD.exe windows by their titles"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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\u2019ve 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not only can users do this from a simple (and colorful) text-based GUI, developers can also use it\u2019s simple, built in commands designed for batch coders!<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"CMDS by IT Command | A Developer Tool for Viewing CMD Windows\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/iYVIt0qrBSI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">CMDS is a pretty simple tool to use. Here\u2019s the help documentation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CMDS Command Prompt Window Lister by IT Command\n\nCMDS &#091;\/S] &#091;\/P] &#091;\/L] &#091;\/W] &#091;\/V] &#091;\/Ver] &#091;\/G Num] &#091;\/K Num] &#091;\/TK String] &#091;\/TS String]\n\n \/S         Displays the simple but high information version (fast)\n \/P         Pauses Before Exiting. Usefull if using from Run.\n \/L         Pauses and refreshes on press of key. Use CTRL+C to quit.\n \/W         Refreshes only when a new cmd instance starts (new PID).\n \/G         For use when listing entries. Copies an entry from a\n            displayed list to clipboard.\n \/K         For use when listing entries. Kills an entry from\n            displayed list.\n Note:      \/G and \/K will pull numbers and PIDs from the previous CMDS\n            list through a variable to increase accuracy.\n Num        The number of the entry to copy to clipboard or kill.\n \/V         Ignores unnamed windows.\n \/Ver       Prints the current version of CMDS and allows you to check\n            for an update. \/version may also be used.\n \/TS        Use within a batch file to search for a Window Title.\n \/TK        Use within a batch file to kill a matching Window Title.\n String     The Window Title to search for with \/TS or \/TK\n\n\n with \/TS the errorlevel will be set to 1 if the title was not found.\n If it is found, the errorlevel will be set to the PID of the cmd instance.\n\n\nExample:\n\n   CMDS \/TS \"My Window\"\n\n    The Above Command Will set the errorlevel to the PID of the cmd instance\n    with the title \"My Window\" (set with the title command). If the instance\n    is not found (there is no running window) the errorlevel will be 1.\n    if the Syntax was incorrect, errorlevel will be set to 2.\n\n\n Created by Lucas Elliott with IT Command  www.itcommand.net<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">There\u2019s 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:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/batch-man.com\/wp-content\/uploads\/2020\/09\/Screenshot-2020-09-21-095001.png\" alt=\"\" class=\"wp-image-670\"\/><figcaption>screenshot of CMDS<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">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&nbsp;<code>\/v<\/code>&nbsp;to the CMDS command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Users can also use&nbsp;<code>CMDS \/w<\/code>&nbsp;which will refresh whenever a CMD window is opened or closed in order to display an up-to-date list at all times.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, CMDS\u2019 more advanced functionality is in its&nbsp;<code>\/TS<\/code>&nbsp;functionality. In the example above, there is a batch file running called \u201cCrafty Controller\u201d. Let\u2019s 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:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CALL CMDS \/TS \"Crafty Controller\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">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!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What if you weren\u2019t sure it was running? Well, if CMDS doesn\u2019t find an instance running with the given title, it sets the errorlevel to 1. Pretty easy!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>taskkill \/f \/pid %errorlevel%<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">However, in this example it gets easier. CMDS now has a built in feature to kill tasks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CALL CMDS \/TK \"Crafty Controller\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also kill tasks from a cmds list and copy task PID\u2019s from the numbered list in CMDS.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cmds \/k 1<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>CMDS \/G 3<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">How easy is that? Obviously this is a powerful tool for batch developers. It\u2019s written 100% in batch with no executables or dependencies. The code is, of course, open source and under the GNU public license.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-background has-black-background-color has-black-color is-style-wide\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><h2 class=\"release-downloads-header\">CMDS Version 23<\/h2><div class=\"release-description\"><p><strong>CMDS Version 23<\/strong> adds severe stability overhauls and adds a versioning system.<\/p>\n<p>Check the readme for more information.<\/p>\n<p>This version also adds optional installers.\nAll the installers do is drop CMDS.exe into the system32 folder.<\/p>\n<p><strong>Note:<\/strong> 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.<\/p><\/div><ul class=\"release-downloads\"><li><a href=\"https:\/\/github.com\/ITCMD\/CMDS\/releases\/download\/23\/CMDS.bat\" rel=\"nofollow\"><strong class=\"release-name\">CMDS.bat<\/strong> <small class=\"release-size\">15.18 KB<\/small> <small class=\"release-download-count\">77 downloads<\/small><\/a><\/li><li><a href=\"https:\/\/github.com\/ITCMD\/CMDS\/releases\/download\/23\/CMDS.Installer-v23.32Bit.exe\" rel=\"nofollow\"><strong class=\"release-name\">CMDS.Installer-v23.32Bit.exe<\/strong> <small class=\"release-size\">1.11 MB<\/small> <small class=\"release-download-count\">38 downloads<\/small><\/a><\/li><li><a href=\"https:\/\/github.com\/ITCMD\/CMDS\/releases\/download\/23\/CMDS.Installer-v23.64Bit.exe\" rel=\"nofollow\"><strong class=\"release-name\">CMDS.Installer-v23.64Bit.exe<\/strong> <small class=\"release-size\">1.11 MB<\/small> <small class=\"release-download-count\">85 downloads<\/small><\/a><\/li><li><a href=\"https:\/\/github.com\/ITCMD\/CMDS\/archive\/23.zip\" rel=\"nofollow\"><strong class=\"release-source\">Source code<\/strong><\/a><\/li><\/ul><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">212 recent downloads.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-background has-black-background-color has-black-color is-style-wide\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/ITCMD\/CMDS\" data-type=\"URL\" data-id=\"https:\/\/github.com\/ITCMD\/CMDS\" target=\"_blank\" rel=\"noreferrer noopener\">View the GitHub<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u2019ve 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&#8230;<\/p>\n","protected":false},"author":1,"featured_media":35,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[6,7,10,9,8],"class_list":["post-25","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-batch","category-tools","tag-batch","tag-cmds","tag-gui","tag-open-source","tag-title"],"_links":{"self":[{"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":10,"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":51,"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/posts\/25\/revisions\/51"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/media\/35"}],"wp:attachment":[{"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/programs.lucas-elliott.com\/index.php\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}