10 Ways to Run Batch Files Silently & Hide CMD Window

.

Convert a Batch Script Into an Executable File

Another way to run a quiet batch file is by turning the script into an executable file. Using the right batch file to executable converter will give the option to suppress the window. One issue is a converted batch script can be flagged by security software as malicious.

Bat To Exe Converter

Bat To Exe Converter by F2KO Software is an easy converter to use while still offering additional features for intermediate and advanced users. The downloaded Zip includes both installer and portable versions and several example batch files. Note we are not using the latest version of the tool as this older one is simpler to use and does everything needed.

Drop a batch file onto the window or browse for it manually, select the Invisible application radio button and click Compile. This will auto create an executable with the same name as the batch script. Use the “Add administrator manifest” option if your script has commands that require administrator privileges. The other options are more for advanced users and not essential.

f2ko bat to exe converter

Another feature is a number of built in script commands. You can add these into your script to make certain command line tasks, which are not built into Windows, easy to accomplish. File requesters, message/input boxes, reading clipboard data and getting file checksums are just a few. There are around 100 commands to use and you can edit your script from the built in editor which includes syntax highlighting.

Download Bat To Exe Converter


Slimm Bat To Exe Converter

Using the Slimm batch to executable converter is just about as easy as you could wish to get, but if you want a little more power a couple of extra options are also available. It’s also a portable tool.

slimm bat to exe converter

To quickly create an executable from a batch file that won’t pop up a console window, click the Windowless Express button, browse for the script and it will automatically create the executable file at the same location as the batch file. The Custom button offers the chance to use an integrated text editor where you can also add your own custom icon from the editor’s Tools > Options menu.

Download Slimm Bat To Exe Converter

Create An Executable Batch File Without Extra Software

It is possible to convert a batch script into an executable in Windows without using any third party software at all. This is achieved through the use of an old tool called IExpress that has been around since Windows 2000 and is still there in Windows 10. IExpress creates a self extracting archive that’s designed more for installation packages, but it works for a single batch file as well.

microsoft iexpress

The IExpress Wizard can be used to manually guide you through creating a self extracting package although we have a much easier way of doing it here. Just download the Zip file below and extract the batch file. Then drop your own batch file onto it and in a few seconds, an executable file will be created by IExpress at the same location.

create executable with iexpress

Do note that if your batch file creates output, such as a log file, you need to make sure to set proper paths or any files created will be deleted once the script terminates. While running, the extracted files are stored in %TEMP%. The script was originally created by a user called “npocmaka” on Github and then modified slightly for drag and drop by another user on Stackoverflow.

Download bat2exeIEXP

Create Your Own Executable File

This method is somewhat similar to turning a batch script into an executable, but you create the code and compile the program yourself. For that, a programming or scripting language is required. We have chosen AutoIt but you can use the similar AutoHotkey or something else if you have another favorite.

Here are four lines of AutoIt code to produce a quietly running batch file:

#RequireAdmin
#AutoIt3Wrapper_UseUpx=y
FileInstall(“MyBatchFile.bat”, @TempDir & “\MyBatchFile.bat”,1)
Run(@ComSpec & ” /c ” & @TempDir & “\MyBatchFile.bat”, “”, @SW_HIDE)

run silent batch autoit

The code is simple to understand, line 1 is optional and asks for administrator privileges, line 2 is also optional and compresses the executable. Line 3 embeds MyBatchFile.bat in the executable and extracts it to the Windows Temp folder on launch. The final line runs the batch file as a console command with the hide attribute suppressing the window.

To simplify the process you can compile the executable with just the last line if you want to run a batch file silently that is stored in a permanent location on your computer.

Run(@ComSpec & ” /c ” & “C:\Scripts\MyBatchFile.bat”, “”, @SW_HIDE)

The above will silently execute MyBatchFile.bat from the C:\Scripts folder. To use AutoIt all you have to do is install it or use the portable version, create your code and press F7 to compile. Make sure the batch file to embed is placed in the same folder as the .au3 AutoIt script file.

Download AutoIt (Download the Zip for the portable version)

Run a Silent Batch Script Using a Scheduled Task

This last method is one that doesn’t need any third party tools, only the Windows Task Scheduler is used. All you have to do is point to the batch file and tick a few boxes. This is obviously best for scripts launching on startup, logon or at a specific date and time, although you can also run the task on demand.

1. Go to Control Panel > Administrative Tools > Task Scheduler, or type Task Scheduler into the Start or taskbar search box.

2. Click Create Basic Task and give the task a name, click Next and select when you would like to launch the task.

3. In the Action window leave “Start a program” selected and after clicking Next, browse for the batch script. Add a path to the “Start in” box if you wish to use a different working path for the batch file. Before clicking Finish to close the wizard, check the box to open the properties dialog.

create a basic task

4. In the Properties window select “Run whether user is logged on or not“, you will need to enter the account password when editing is done. If there’s no password on the account, also check the “Do not store password” box. This does have a drawback because the batch script will not be able to access file, folder or printer shares. If you don’t set these options a console window opens while running the script.

run whether user is logged in or not option

5. If the batch script needs administrator privileges, tick the “Run with highest privileges” box. Click OK when done.

create scheduled task with highest privileges

Now you can test the task works by right clicking and selecting Run or waiting for it to run at the scheduled point or time. It should work and without popping up any type of console window.

Running The Scheduled Task On Demand

While the task can be run on the schedule you supplied when creating it, you can also execute it whenever you want. This has an extra bonus because you can run a batch file that requires administrator privileges at any time without having a UAC prompt appear (doesn’t work for standard user accounts).

Create a new shortcut on the desktop and in the location box enter the following:

Schtasks.exe /Run /TN “Task Name”

Replace Task Name with the specific name you gave the task in step two above.

create scheduled tasks shortcut

Now you can run the batch file silently at any time and without any UAC prompts appearing. This method is actually pretty useful for running any type of program silently in the background and without a UAC prompt.

Tip: If you want to run the task on demand only and not with any triggers, go back into the Task Scheduler Properties window (step four above), click the Triggers tab, select the trigger in the list and delete it.

25 Comments - Write a Comment

  1. amymor 2 years ago
    • HAL9000 2 years ago
  2. Jon 2 years ago
  3. J 2 years ago
    • HAL9000 2 years ago
  4. random user 3 years ago
    • HAL9000 3 years ago
  5. Charles Nelson 4 years ago
  6. Novabin 4 years ago
  7. Alex Gorky 4 years ago
    • HAL9000 4 years ago
      • Mike 4 years ago
  8. Alex 6 years ago
  9. Yasser 6 years ago
  10. Kiran Vadday 6 years ago
  11. Jeremy 6 years ago
  12. Nagesh 6 years ago
  13. Myself 6 years ago
    • HAL9000 6 years ago
      • H K 2 years ago
  14. Jeerapong Putthanbut 6 years ago
  15. Squashman 6 years ago
    • HAL9000 6 years ago
  16. Me 7 years ago
  17. Nasser 7 years ago

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: Your comment is subject to approval. Read our Terms of Use. If you are seeking additional information on this article, please contact us directly.