banner



How To Run A Batch File In Background

Most ordinary Windows users never utilise the Command Prompt and have no thought what sort of things you can practice from the command line. More than experienced users volition know that running command line commands can be very useful for a range of tasks and group everything into a single batch file to procedure it all together can be very powerful.

One inconvenience with running batch files is that they always open a console window which shows the output of the commands beingness executed. This can exist of import if y'all want to interact or run into what is happening while the batch file is running but a bit annoying if you want to run the batch script quietly in the groundwork or while starting windows.

batch file console output

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 style to completely hide the console window from showing and then if you desire to practise that another solution is required. Here we evidence yous some different ways to make your batch script run silently without a panel window showing.

Notation:

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 information technology exits, such as break or requiring user input like a Yes/No response. For case, if a script has been converted into an executable and requires interaction, you won't exist able to exercise anything and the process volition stay in Task Manager until it'due south manually killed.

Run a Silent Batch Script Using a Third Political 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 Kickoff is a portable and quite powerful tool that can launch executables and scripts with several useful options. We are using version iv.two from 2013 because it's portable and not as restricted as newer versions. Since version 4.3, Hidden Start is no longer portable and besides pops up a nag every time you try to run a subconscious console, which makes it useless for this purpose.

hidden start

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 certain "Hide console window" is checked and optionally bank 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.

Footstep three shows the output control that has to exist manually run. You tin can use the buttons at the bottom to re-create the command, automatically create a shortcut or add together 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 gratis later).

Download Hidden Start


SilentCMD

This is a small 14KB tool that is non blessed with tons of features just does the simple task which nosotros are looking for. If y'all are on Windows 10, .NET Framework 3.5 will exist offered for install when running the tool if it isn't already on your system. The bones syntax to use in shortcuts or similar is quite uncomplicated.

SilentCMD [path to .bat file] [batch arguments] [options]

silentcmd

There are two additional options in SilentCMD. One is to enable logging with "/log:[path to .txt]" and the other is to get-go the script after a delay using "/DELAY:[twenty seconds]". Append the option to the terminate of the command. As long equally yous don't need extra functions like summit or a unlike starting directory, SilentCMD works nicely and might exist all that y'all demand.

Download SilentCMD


NirCMD

Nirsoft's NirCMD is a minor multi part tool that can quietly perform dozens of tasks without popping upwardly whatever 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 hibernate commands are used to execute the script and hibernate any panel windows from opening.

create silent batch with nircmd

Include elevatecmd to asking ambassador privileges for the batch file although it's just needed if yous know commands in your script crave elevation.

nircmd elevatecmd exec hibernate [path to .bat file]

A desktop shortcut can exist created manually or you can tell NirCMD to create a shortcut from the control line with the included commands then the silent script is ready to run.

nircmd cmdshortcut "~$folder.desktop$" "SilentBatch" exec hide C:\Users\Raymondcc\MyBatchFile.bat

The higher up will create a desktop shortcut called SilentBatch which volition silently execute the MyBatchFile.bat script. Annotation that you may have to modify the "Showtime in" location in the shortcut every bit output from the script that doesn't supply a path will default to C:\Windows.

change start in location for nircmd shortcut

On double clicking the NirCMD executable it will offer the option to copy itself to the Windows directory so yous only have to use nircmd.exe and non supply a full path every time. It's advisable to practice that if you programme to make use of NirCMD on your calculator (make sure to right click and run nircmd.exe as administrator).

copy nircmd executable to windows

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 tin 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 2. Silent Batch Launcher is designed to exist elementary to use and provide a slightly different option to the other tools hither.

Run the executable and y'all will be asked to scan for a batch file. An INI file containing the path to the script will then be created adjacent to the executable. Every time you run Silent Batch Launcher from and so on it will execute the same batch file as long as the INI file is present.

raymondcc silent batch launcher

To run a dissimilar script, delete the INI file or concord Shift while launching the tool and it volition 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 aforementioned folder. In that location are two files in the archive, use the "Admin" version if the script requires height. Any useful feedback you lot 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 hibernate the console window of a batch script that we haven't mentioned hither. 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 equally an statement, then the code runs the script while not showing whatsoever output. It tin can be washed 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 and so save it as a .vbs file. Alternatively,download launchquiet.vbs which is a gear up made script. To add it to a shortcut or a startup location etc, use the commands in the following mode. Don't forget to use quotes if your paths or filenames contain spaces.

Wscript [path to .vbs file] [path to .bat file]

create a shortcut for launchquiet script

If you would similar to supply an argument for the batch file, the piece of VB script has to be contradistinct slightly by changing the two sets of four double quotes to two sets of two.

CreateObject("Wscript.Beat out").Run "" & WScript.Arguments(0) & "", 0, Simulated

And so supply the arguments along with the batch script path inside quotes:

Wscript [path to .vbs file] "[path to .bat file] [argument]"

Again, for convenience, yous tin can download a set made launchquiet_args.vbs script file.

On the next folio, we'll look at how to catechumen a batch script into an executable file, how to create a batch executable without whatsoever additional software and how to run a script from a scheduled task.

How To Run A Batch File In Background,

Source: https://www.raymond.cc/blog/hidden-start-runs-batch-files-silently-without-flickering-console/

Posted by: joneslessed.blogspot.com

0 Response to "How To Run A Batch File In Background"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel