Most ordinary Windows users never use the Command Prompt and have no idea what sort of things you can do from the command line. More experienced users will know that running command line commands can be very useful for a range of tasks and grouping everything into a single batch file to process it all together can be very powerful.
This can be important if you want to interact or see what is happening while the batch file is running but a bit annoying if you want to run the batch script quietly in the background or while starting windows. For short batch files, the console window may appear and disappear in a flash or stay open for longer if more commands are being executed. 3 Ways To Prevent Command Prompt From Closing After Running Commands (Batch File Pause) Maham Mukhtar command prompt 5 Comments March 30, 2017 When we run any batch file, the Command Prompt window will appear shortly and it goes on the same time and you do not exactly get what commands run on CMD as the result of the batch file. Windows batch file not running when I double click, how to restore association with cmd.exe? Ask Question Asked 3 years. How do I get current logged in user name when running a batch file as administrator. Windows batch file not running when double clicked. Windows 7 Admin user - batch file always runs as Administrator. Microsoft Windows users can run batch files or other files in a minimized window by using the command prompt start command. Running a batch file minimized is useful for when you need to run a batch file but don't want the user to interrupt its operation. Apr 26, 2017 Running a batch file from within Windows. However, because a batch file runs in a command line, it immediately exits when done, so you may only see a black box for a second. Tip: If the batch file is closing too fast, or you want to read the output from the batch file, you can edit the batch file and add a pause to the end of the file.
One inconvenience with running batch files is that they always open a console window which shows the output of the commands being executed. This can be important if you want to interact or see what is happening while the batch file is running but a bit annoying if you want to run the batch script quietly in the background or while starting windows.
For short batch files, the console window may appear and disappear in a flash or stay open for longer if more commands are being executed. There is no standard built in way to completely hide the console window from showing so if you want to do that another solution is required. Here we show you some different ways to make your batch script run silently without a console window showing.
Note: When using a method to hide the console window make sure the batch script contains no commands that are likely to stop the script before it exits, such as pause or requiring user input like a Yes/No response. For example, if a script has been converted into an executable and requires interaction, you wonât be able to do anything and the process will stay in Task Manager until itâs manually killed.
Run a Silent Batch Script Using a Third Party Utility
A simple and common solution for running a batch file silently is launching it via a third party utility that suppresses the console window.
Hidden Start (HStart)
Hidden Start is a portable and quite powerful tool that can launch executables and scripts with several useful options. We are using version 4.2 from 2013 because itâs portable and not as restricted as newer versions. Since version 4.3, Hidden Start is no longer portable and also pops up a nag every time you try to run a hidden console, which makes it useless for this purpose.
Unzip and run the program with HStartUI.exe, the process consists of three steps. Manually add or drop your batch file onto the window, make sure âHide console windowâ is checked and optionally check âRun with highest privilegesâ if your script requires it. Other setup options like priority or starting directory are not essential unless you know the script requires them.
Step 3 shows the output command that has to be manually run. You can use the buttons at the bottom to copy the command, automatically create a shortcut or add an autostart entry into the registry. Note the bypass UAC prompt option is not available in the free version (we show you how to do that for free later).
Download Hidden Start
SilentCMD
This is a small 14KB tool that is not blessed with tons of features but does the simple task which we are looking for. If you are on Windows 10, .NET Framework 3.5 will be offered for install when running the tool if it isnât already on your system. The basic syntax to use in shortcuts or similar is quite simple.
In this video tutorial you will learn how to Install HP Mobile Broadband Module Device for and how to active sim card device and how to use internet on PC using Sim Internet connection.
SilentCMD [path to .bat file] [batch arguments] [options]
There are two additional options in SilentCMD. One is to enable logging with â/log:[path to .txt]â and the other is to start the script after a delay using â/DELAY:[xx seconds]â. Append the option to the end of the command. As long as you donât need extra functions like elevation or a different starting directory, SilentCMD works nicely and might be all that you need.
Download SilentCMD
NirCMD
Nirsoftâs NirCMD is a small multi function tool that can quietly perform dozens of tasks without popping up any console window. These include ejecting ROM drives, changing audio volumes, enabling screensavers, controlling processes/services and much more. The following command can be used at boot or in a shortcut to run a batch file silently:
nircmd exec hide [path to .bat file]
The exec and hide commands are used to execute the script and hide any console windows from opening.
Include elevatecmd to request administrator privileges for the batch file although itâs only needed if you know commands in your script require elevation.
nircmd elevatecmd exec hide [path to .bat file]
A desktop shortcut can be created manually or you can tell NirCMD to create a shortcut from the command line with the included commands so the silent script is ready to run.
nircmd cmdshortcut â~$folder.desktop$â âSilentBatchâ exec hide C:UsersRaymondccMyBatchFile.bat
The above will create a desktop shortcut called SilentBatch which will silently execute the MyBatchFile.bat script. Note that you may have to change the âStart inâ location in the shortcut as output from the script that doesnât supply a path will default to C:Windows.
On double clicking the NirCMD executable it will offer the option to copy itself to the Windows directory so you only have to use nircmd.exe and not supply a full path every time. Itâs advisable to do that if you plan to make use of NirCMD on your computer (make sure to right click and run nircmd.exe as administrator).
For full information about the wealth of commands available, have a read of the full NirCMD Help file.
Download NirCMD
Raymond.cc Silent Batch Launcher
We also have a little tool that can launch a batch file silently. Itâs created in Autoit and is essentially a slightly advanced version of the âCreate Your Own Executable Fileâ method on page two. Silent Batch Launcher is designed to be simple to use and provide a slightly different option to the other tools here.
Run the executable and you will be asked to browse for a batch file. An INI file containing the path to the script will then be created next to the executable. Every time you run Silent Batch Launcher from then on it will execute the same batch file as long as the INI file is present.
To run a different script, delete the INI file or hold Shift while launching the tool and it will popup the file requester. The INI file name will match the EXE file name so you can have differently named occurrences of the tool in the same folder. There are two files in the archive, use the âAdminâ version if the script requires elevation. Any useful feedback you have about the tool is welcome.
Download Silent Batch Launcher
Note: Because this tool was created with Autoit, it does create some false positives with online virus scanners like VirusTotal.
There are a few other tools that can hide the console window of a batch script that we havenât mentioned here. They include Cmdow, Create Hidden Process, Hidecon, and Hideexec.
Hide the Batch Console With a Visual Basic Script
Hiding the batch script console window using Visual Basic is quite similar to using an external command and works in basically the same way. Launch the VB script and supply the batch file as an argument, then the code runs the script while not showing any output. It can be done with a single line of code.
CreateObject(âWscript.Shellâ).Run ââââ & WScript.Arguments(0) & ââââ, 0, False
Create an empty text file, copy and paste the above line then save it as a .vbs file. Alternatively, download launchquiet.vbs which is a ready made script. To add it to a shortcut or a startup location etc, use the commands in the following way. Donât forget to use quotes if your paths or filenames contain spaces.
Wscript [path to .vbs file] [path to .bat file]
If you would like to supply an argument for the batch file, the piece of VB script has to be altered slightly by changing the two sets of four double quotes to two sets of two.
CreateObject(âWscript.Shellâ).Run ââ & WScript.Arguments(0) & ââ, 0, False
Then supply the arguments along with the batch script path inside quotes:
Wscript [path to .vbs file] â[path to .bat file] [argument]â
Again, for convenience, you can download a ready madelaunchquiet_args.vbs script file.
On the next page, weâll look at how to convert a batch script into an executable file, how to create a batch executable without any additional software and how to run a script from a scheduled task.
1
You might also like:7 Ways to Measure Time Taken to Complete a Batch File or Command Line Execution6 Ways To Batch Create Multiple Folders at Once5 Ways to Trigger UAC Elevation from Command Line7 Ways To Remove Duplicate Lines in Text Files2 Ways to Convert REG to EXE, BAT, VBS and AU3 to Bypass Registry Editing Restriction
Alex5 months ago
Here is another implementation: stackoverflow.com/a/56111754/70405
Reply
Thank you for nice article, after a research found nircmd is the easiest and best utility
Reply
Kiran Vadday7 months ago
Hi Jeremy,
Can I add the lines provided by you directly in my batch file after @echo off?
Thank you, Reply
Kiran.
Another option: create a Windows shortcut and use this as the path:
cmd.exe /c echo CreateObject(âWscript.Shellâ).Run ânotepad.exeâ, 0, false > run_hidden.vbs & start /wait wscript run_hidden.vbs & del run_hidden.vbs
Reply
Nagesh8 months ago
Thank you This helped me a lot.
Reply
âRun whether user is logged on or not will not work no matter what you doâ Reply
True!
HAL9000 Author9 months ago
You need to use that or it wonât hide the console window, if you use ârun only when user is logged inâ, a console window will appear, which is what we a trying to avoid.
Reply
Thank you so much!!
Reply
Squashman11 months ago
You missed a tool that has been around for 16 years. Reply
joeware.net/freetools/tools/quiet/index.htm
The article is not about listing every single tool around that can hide a console window.
Reply
Me1 year ago
Thanks a lot for âRun A Silent Batch Script Using A Scheduled Taskâ. Reply
It saved me a 2 minutes popup every 10 minutes :)
Run whether user is logged on or not will not work no matter what you do
Reply
Leave a Reply
On Windows 10, a batch file is a special kind of text file that typically uses a .bat extension, which can include one or multiple commands that Command Prompt can understand and run in sequence to perform various actions.
Usually, you can just input commands manually to perform a particular task, but a batch file simplifies the work of retyping commands, saving you time.
Also, even though, there are other tools, such as PowerShell, that write more advanced scripts, using batch files with Command Prompt is an effective option when you need to run commands to change system settings, automate routines, and launch applications or websites.
In this Windows 10 guide, we walk you through the steps to get started creating and running your first batch file on your computer.
How to create a batch file on Windows 10
The process to write a batch (script or batch script) file is easy. You only need a text editor and a little bit of knowledge to run commands on Command Prompt. In the steps below, we detail the steps for creating a simple and advanced batch file, as well as the steps to write a script to change the system settings.
Writing a simple batch file
To create a simple batch file on Windows 10, use these steps:
Once you complete these steps, you can double-click the file to run it, or you can use the steps below to learn the different ways to execute a batch file on Windows 10.
Writing an advanced batch file
To create an interactive batch file that executes multiple commands, use these steps:
After you complete these steps, you can run the script double-clicking the .bat file, or you can use the steps below to learn the different ways to execute a batch on Windows 10.
Writing an actionable batch file
You're not limited to showing information on a Windows 10 console. You can also write non-interactive batch files to perform virtually any task. For example, to write a batch file that runs a specific command without the need for user interaction, use these steps:
Once you complete these steps, when you run the batch file, the command will map a shared network folder with the settings you specified without the need to open Command Prompt to type the commands manually. Although we only specified one command in the file, you can include as many commands as you like, as long as you write one per line.
How to run a batch file on Windows 10
On Windows 10, there are a least three ways to run a batch file. You can run a batch on-demand (using File Explorer or Command Prompt). You can create a scheduled task using the Task Scheduler. Or you can place the script in the Startup folder to run it every time you sign into your computer.
Running batch file on-demand
When you need to run a batch file on-demand, you can use File Explorer or Command Prompt.
File ExplorerWindows Batch File Example
To run a batch file using File Explorer, use these steps:
After completing the steps, the batch will run each command in sequence displaying the results on the screen.
Command Prompt
To run a batch file from Command Prompt, use these steps.
Once you run the command, the output will display on the screen regardless of the script containing the 'PAUSE' command or not.
Running batch file on scheduled
To schedule a batch file on Windows 10, you'll need to use the Task Scheduler with these steps:
Run Windows Batch File From Linux
Once you complete these steps, the task will be saved, and it'll run the batch file on the schedule you specified.
These instructions cover the steps to create a basic task. If you want to create a more customizable task, use this guide.
Running batch files on startup
Alternatively, if you want to run a batch file every time that you sign into your account, use these easy steps:
Running Batch File In Background
After completing the steps, every time you sign in to your account, the batch file will automatically execute in sequence the commands you wrote.
This guide is focused on Windows 10, but the ability to use batch files has been around for many years, which means that you can refer to these instructions if you're still running Windows 8.1, Windows 7, or an older version.
More Windows 10 resourcesRun Bat File Windows 10
For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |