{"id":371,"date":"2024-02-09T18:43:11","date_gmt":"2024-02-09T18:43:11","guid":{"rendered":"https:\/\/tech.nes.aau.at\/?p=371"},"modified":"2024-02-09T18:43:11","modified_gmt":"2024-02-09T18:43:11","slug":"windows-bat-file-command-line-tool-wait-for-keypress-when-double-clicked","status":"publish","type":"post","link":"https:\/\/tech.nes.aau.at\/?p=371","title":{"rendered":"Windows .bat file command line tool, wait for keypress when double-clicked"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Windows .bat files can be a convenient and quick way to automate things, like, for example, a compilation command involving a lot of options. They can be executed from the command line or by double-clicking them from the explorer. In the latter case, one would want the script to wait for a keypress until they close the window. When started from the command line, the waiting from a keypress is rather annoying.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is possible to make the script behave differently depending on the way it was executed:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>IF \/I %0 EQU \"%~dpnx0\" PAUSE<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This executes the PAUSE command when the file was started by double-click.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Source: <a href=\"https:\/\/stackoverflow.com\/questions\/5859854\/detect-if-bat-file-is-running-via-double-click-or-from-cmd-window\">Detect if bat file is running via double click or from cmd window<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows .bat files can be a convenient and quick way to automate things, like, for example, a compilation command involving a lot of options. They can be executed from the command line or by double-clicking them from the explorer. In &hellip; <a href=\"https:\/\/tech.nes.aau.at\/?p=371\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[26,21],"class_list":["post-371","post","type-post","status-publish","format-standard","hentry","category-tips","tag-programming","tag-windows"],"_links":{"self":[{"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=\/wp\/v2\/posts\/371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=371"}],"version-history":[{"count":1,"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=\/wp\/v2\/posts\/371\/revisions"}],"predecessor-version":[{"id":372,"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=\/wp\/v2\/posts\/371\/revisions\/372"}],"wp:attachment":[{"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.nes.aau.at\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}