{"id":425,"date":"2008-08-05T09:48:37","date_gmt":"2008-08-05T04:18:37","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=425"},"modified":"2019-04-22T17:22:51","modified_gmt":"2019-04-22T17:22:51","slug":"run-bat-files-invisibly-without-displaying-command-prompt","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/run-bat-files-invisibly-without-displaying-command-prompt\/","title":{"rendered":"How to run .BAT files invisibly, without displaying the Command Prompt window"},"content":{"rendered":"<p>Batch files (.BAT) and Windows NT Command Script (.CMD) files run in console window when double-clicked. This means that the Command Prompt window will be visible until the .BAT or .CMD file execution is complete.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/08\/batch-file-run-invisible-hidden-mode.png\" alt=\"run batch file hidden or invisible mode\" width=\"701\" height=\"221\" class=\"alignnone size-full wp-image-8801\" \/><\/p>\n<p>To make .BAT or .CMD file execution less intrusive, you can configure it to run minimized. Or if the .BAT or .CMD file does not require user input during run time, you can launch it in invisible mode using a Script.<\/p>\n<p>The built-in Task Scheduler in Windows is capable of launching programs in hidden mode. If you don&#8217;t want to proceed via the Task Scheduler route, check out the options discussed in this article.<!--more--><\/p>\n<div id=\"toc\">\n<img loading=\"lazy\" decoding=\"async\" class=\"alignright\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/batfile-icon.png\" width=\"35\" height=\"35\" \/><\/p>\n<ol>\n<li><a href=\"#minimized\">Run a Batch or CMD file in minimized window mode<\/a><\/li>\n<li><a href=\"#script\">Run a Batch or CMD file hidden (invisible mode) via Windows Script<\/a><\/li>\n<li><a href=\"#nircmd\">Run a Batch or CMD file hidden (invisible mode) using NirCmd utility<\/a><\/li>\n<\/ol>\n<\/div>\n<h2><a id=\"minimized\"><\/a>Running .BAT or .CMD files in minimized mode<\/h2>\n<p>To run a batch file in a minimized window state, follow these steps:<\/p>\n<ol>\n<li>Create a shortcut to the .BAT or .CMD file. To do so, right click on the file, click <b>Send To<\/b>, <b>Desktop (create shortcut)<\/b><\/li>\n<li>Right click on the shortcut and choose <b>Properties<\/b><\/li>\n<li>In the <b>Run:<\/b> drop down, choose <b>Minimized<\/b><\/li>\n<li>Click OK<\/li>\n<li>Double-click the shortcut to run the batch file in a minimized window state.<\/li>\n<\/ol>\n<h2><a id=\"script\"><\/a>Running .BAT or .CMD files hidden (invisible mode) Using Script<\/h2>\n<p>Windows Script Host&#8217;s <b>Run<\/b> Method allows you run a program or script in invisible mode. Here is a sample Windows script code that launches a batch file named <code>syncfiles.bat<\/code> invisibly.<\/p>\n<p><em>Reference: <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/d5fk67ky(VS.85).aspx\" target=\"_blank\" rel=\"noopener noreferrer\">Run Method<\/a>. Setting <b>intWindowStyle<\/b> parameter to 0 hides the window.<\/em><\/p>\n<p>Let&#8217;s say we have a file named <code>syncfiles.bat<\/code> in <code>C:\\Batch Files<\/code> directory. Let&#8217;s launch it in hidden mode using Windows Scripting.<\/p>\n<ol>\n<li>Copy the following lines to Notepad.\n<pre>Set WshShell = CreateObject(\"WScript.Shell\") \r\nWshShell.Run chr(34) &amp; \"C:\\Batch Files\\syncfiles.bat\" &amp; Chr(34), 0\r\nSet WshShell = Nothing<\/pre>\n<p><em><strong>Note:<\/strong> Replace the batch file name\/path accordingly in the script according to your requirement.<\/em><\/li>\n<li>Save the file with .VBS extension, say <code>launch_bat.vbs<\/code><\/li>\n<li>Edit the .BAT file name and path accordingly, and save the file.<\/li>\n<li>Double-click to run the launch_bat.vbs file, which in-turn launches the batch file <code>syncfiles.bat<\/code> invisibly.<\/li>\n<\/ol>\n<p><strong>RELATED:<\/strong> <em><a href=\"https:\/\/www.winhelponline.com\/blog\/automatically-elevate-batch-file-run-administrator\/\">How to Automatically Elevate a Batch file to Run it as Administrator?<\/a><\/em> -and- <a href=\"https:\/\/www.winhelponline.com\/blog\/vbscripts-and-uac-elevation\/\">VBScripts and UAC elevation (Run as administrator)<\/a><\/p>\n<h2><a id=\"nircmd\"><\/a>Running .BAT or .CMD files hidden (invisible mode) Using NirCmd<\/h2>\n<p>NirCmd is a multipurpose command-line automation utility from the third-party vendor Nirsoft. We&#8217;ve <a href=\"https:\/\/www.winhelponline.com\/blog\/?s=nircmd\">covered NirCmd<\/a> many times in the past on our site.<\/p>\n<p>We can use NirCmd to run a program, script or batch file in hidden mode.<\/p>\n<p>Download <a href=\"https:\/\/www.nirsoft.net\/utils\/nircmd.html\" rel=\"noopener noreferrer\" target=\"_blank\">NirCmd<\/a> and extract the file to your Windows directory.<\/p>\n<p>From the Run dialog or Command Prompt, use the following syntax to launch a batch file or program in hidden mode:<\/p>\n<pre>nircmd exec hide [path to batch file]<\/pre>\n<p><strong>Example:<\/strong><\/p>\n<pre>nircmd exec hide \"c:\\batch files\\syncfiles.bat\"<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2008\/08\/nircmd-batch-file-hidden.png\" alt=\"run batch file hidden - nircmd exec\" width=\"399\" height=\"206\" class=\"alignnone size-full wp-image-8802\" \/><\/p>\n<p>If you need to run the batch file elevated (as administrator), use the following command instead:<\/p>\n<pre>nircmd elevatecmd exec hide c:\\batch files\\syncfiles.bat<\/pre>\n<p><em>(<a href=\"https:\/\/nircmd.nirsoft.net\/exec.html\" rel=\"noopener noreferrer\" target=\"_blank\">NirCmd Command Reference &#8211; exec<\/a>)<\/em><\/p>\n<p>That&#8217;s it! If you know any other method to run a batch or CMD file in hidden mode, let us know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Batch files (.BAT) and Windows NT Command Script (.CMD) files run in console window when double-clicked. This means that the Command Prompt window will be visible until the .BAT or .CMD file execution is complete. To make .BAT or .CMD file execution less intrusive, you can configure it to run minimized. Or if the .BAT &#8230; <a title=\"How to run .BAT files invisibly, without displaying the Command Prompt window\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/run-bat-files-invisibly-without-displaying-command-prompt\/\" aria-label=\"Read more about How to run .BAT files invisibly, without displaying the Command Prompt window\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6,7],"tags":[335,480],"class_list":["post-425","post","type-post","status-publish","format-standard","hentry","category-utilities","category-windows","tag-nircmd","tag-scripts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":8452,"url":"https:\/\/www.winhelponline.com\/blog\/bat-files-do-not-run-when-double-clicked-fix-association\/","url_meta":{"origin":425,"position":0},"title":"[Fix] Windows Batch Files (.bat) do not run when double-clicked","author":"Ramesh","date":"April 2, 2019","format":false,"excerpt":"When you double-click a Windows batch file (.bat) or a .cmd file, one of the following symptoms may happen: The error \"Windows cannot find 'filename.bat'. Make sure you typed the name correctly, and then try again.\" occurs when you run a .bat or a .cmd file. The batch file opens\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"comspec setx","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/comspec-fix-setx.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/comspec-fix-setx.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2019\/04\/comspec-fix-setx.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3641,"url":"https:\/\/www.winhelponline.com\/blog\/fix-cannot-run-programs-without-typing-extension-exe-command-prompt\/","url_meta":{"origin":425,"position":1},"title":"[Fix] Cannot Run Programs Without Typing the Extension (.EXE) in Command Prompt","author":"Ramesh","date":"July 31, 2016","format":false,"excerpt":"If you're unable to launch programs without having to type the extension \".exe\" in a Command Prompt window, you need to fix your PATHEXT variable. For instance, Notepad may launch correctly when you type Notepad.exe, but not when typing Notepad. The latter might show you the following error: 'notepad' is\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"cannot run programs without typing .exe extension pathext","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/07\/pathext-fix-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/07\/pathext-fix-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/07\/pathext-fix-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":6018,"url":"https:\/\/www.winhelponline.com\/blog\/delete-unused-files-older-than-x-days-windows\/","url_meta":{"origin":425,"position":2},"title":"How to Delete Files Older than N Days Automatically in Windows","author":"Ramesh","date":"December 11, 2017","format":false,"excerpt":"Windows 10 has built-in features to free up space by deleting old files in the %temp% directory and Downloads folder. Windows 10 Settings has an option (\"Storage\") which automatically clears temporary files your apps are not using, files in the Downloads that haven't been modified in the last x days,\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"windows 10 storage settings cleanup options","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/storage-settings-cleanup-options.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/storage-settings-cleanup-options.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/11\/storage-settings-cleanup-options.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1646,"url":"https:\/\/www.winhelponline.com\/blog\/find-unknown-program-open-and-close-immediately\/","url_meta":{"origin":425,"position":3},"title":"Command Prompt Flashes and Closes Quickly at Startup or Random Intervals","author":"Ramesh","date":"February 16, 2016","format":false,"excerpt":"If the Command Prompt, PowerShell, or an unknown program window flashes during logon or at random intervals without you doing anything, there are many chances that it's a Task Scheduler job. The windows popping up frequently can be a huge distraction when you're working or playing a game on the\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"scheduled task list out-gridview - lastruntime","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/schtasks-list-powershell-action-arguments.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/schtasks-list-powershell-action-arguments.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/schtasks-list-powershell-action-arguments.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/schtasks-list-powershell-action-arguments.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/schtasks-list-powershell-action-arguments.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2016\/02\/schtasks-list-powershell-action-arguments.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":153,"url":"https:\/\/www.winhelponline.com\/blog\/change-the-default-editor-for-bat-files\/","url_meta":{"origin":425,"position":4},"title":"Change the Default Editor for Batch files in Windows","author":"Ramesh","date":"April 4, 2008","format":false,"excerpt":"When you right-click on a Windows batch file (.bat) file and click Edit, Notepad opens the file by default. If you have a Notepad replacement software installed in your system, you can set it as the default editor for Windows batch files. Change the Default Editor for Batch Files Launch\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/bat-icon.gif?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":28839,"url":"https:\/\/www.winhelponline.com\/blog\/cant-open-cmd-after-uninstalling-python-anaconda\/","url_meta":{"origin":425,"position":5},"title":"Can&#8217;t Open CMD.exe After Uninstalling Python\/Anaconda; Exit Code 1","author":"Ramesh","date":"September 29, 2022","format":false,"excerpt":"After uninstalling Python\/Anaconda on your Windows computer, Command Prompt may not open. When you run cmd.exe, it flashes on the screen and immediately quits. Also, running DISM and SFC (to repair corrupt system files), repairing Windows installation, and running a thorough malware scan may not fix the issue. Also, when\u2026","rel":"","context":"In &quot;Windows&quot;","block_context":{"text":"Windows","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/"},"img":{"alt_text":"vscode cmd.exe error 1","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2022\/09\/vscode-cmd-error-code-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=425"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/425\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}