JIYIK CN >

Current Location:Home > Learning > OPERATING SYSTEM >

Running a batch script in silent mode

Author:JIYIK Last Updated:2025/03/21 Views:

If you run CMD without silent mode, the command prompt will print every line of code in CMD. This article will show you how to activate CMD silent mode via batch script.

We will also learn different ways to run batch scripts silently. We will look at some examples and explanations to make the topic easier.


Run batch scripts in silent mode using @echo off command

The built-in command in Batch called echo is used for many purposes in scripts. We will include @ in the command echo.

Suppose you add the command at the beginning of the script @echo off. Let's look at the following example.

SET /A x = 15
SET /A y = 25
SET /A z = %x% + %y%
ECHO The sum of a and b is %z%
IF %z% LSS 20 (echo The result is less than 20) ELSE (echo The result is greater than 20)

In the above example, we added two numbers and checked if the number is less than 20. But the point is, if you don’t use the command @echo off at the beginning of the code, you will get an output like the one below.

Output:

C:\Destination\Author>SET /A x = 15

C:\Destination\Author>SET /A y = 25

C:\Destination\Author>SET /A z = 15 + 25

C:\Destination\Author>ECHO The sum of a and b is 40
The sum of a and b is 40

C:\Destination\Author>IF 40 LSS 20 (echo The result is less than 20 ) ELSE (echo The result is greater than 20 )
The result is greater than 20

Now, if you use the command at the beginning of your script @echo off, your output will look like this:

The sum of a and b is 40
The result is greater than 20

So, the command @echo off will turn off the display of each line in the batch script and give nice output.


Using third-party software to run batch scripts silently

Below, we share some third-party software that can be used to execute batch scripts.

Hidden Start (HStart)

Hidden Launch is a powerful and portable tool with which you can apply multiple options to launch scripts and executables. You will have options to hide the console window, run with highest privileges, etc.

To run a batch script with the help of this third-party software, you just need to provide the location of the file and add it to the executable.

SilentCMD

SilentCMD is a small, lightweight third-party tool that can be used to run batch scripts. The basic syntax when running a batch script using SilentCMD is:

SilentCMD [path to your file] [your batch arguments] [ available options]

NirCMD

NirCMD is a third-party software created by NirSoft. It is a small tool with multiple functions that can perform multiple tasks without opening any console window.

The general syntax for using this third-party software is:

nircmd exec hide [ Your Path to file]

Run batch scripts silently using VB scripts

You can run a batch file using Visual Basic Script. To run a batch script with the help of VB Script, you can follow the example below:

SET WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\YourLocation\YourScript.bat" & Chr(34), 0
SET WshShell = Nothing

Run batch scripts silently using Task Scheduler

You can also run the batch script as a scheduled task through Task Scheduler. To do this, you must follow these steps:

  • Open Task Scheduler.
  • Now, click on Create Task.

    Task Scheduler - Creating Tasks

  • Provide your name and required information here.

    Task Scheduler - Provides information

  • Now, click on the Actions tab and then click New.

    Task Scheduler - Click the Actions tab

    Task Scheduler - Click New

  • Now provide the exact location of the batch script, select the action, and provide optional settings if necessary.
  • Finally, click OK in both open windows.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

How to decompress x.tar.xz format files under Linux

Publish Date:2025/04/08 Views:186 Category:OPERATING SYSTEM

A lot of software found today is in the tar.xz format, which is a lossless data compression file format that uses the LZMA compression algorithm. Like gzip and bzip2, it supports multiple file compression, but the convention is not to compr

Summary of vim common commands

Publish Date:2025/04/08 Views:115 Category:OPERATING SYSTEM

In Linux, the best editor should be vim. However, the complex commands behind vim's powerful functions also make us daunted. Of course, these commands do not need to be memorized by rote. As long as you practice using vim more, you can reme

Detailed explanation of command return value $? in Linux

Publish Date:2025/04/08 Views:58 Category:OPERATING SYSTEM

? is a special variable. This variable represents the return value of the previous command. That is to say, when we run certain commands, these commands will return a code after running. Generally, if the command is successfully run, the re

Common judgment formulas for Linux script shell

Publish Date:2025/04/08 Views:159 Category:OPERATING SYSTEM

In shell script programming, predicates are often used. There are two ways to use predicates, one is to use test, and the other is to use []. Let's take a look at how to use these two methods through two simple examples. Example 1 # test –

How to use the Linux file remote copy command scp

Publish Date:2025/04/08 Views:151 Category:OPERATING SYSTEM

Scp copies files between two hosts over the network, and the data is encrypted during transmission. Its underlying layer uses ssh for data transmission. And it has the same authentication mechanism and the same security level as ssh. When u

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial