Comment In Windows Batch File

Posted : admin On 06.08.2019
  1. Batch Script Comments
  2. Multiline Comment In Windows Batch File
  3. Comment In Cmd Batch File

In this chapter, we will learn how to create, save, execute, and modify batch files.

Edit the batch file's contents. At any time, you can right-click your batch file and click Edit in the resulting drop-down menu. This will open the batch file as a Notepad document; at this point, you can make any changes and then save the file by pressing Ctrl+S. The changes will immediately be reflected when you run the batch file. Edit the batch file's contents. At any time, you can right-click your batch file and click Edit in the resulting drop-down menu. This will open the batch file as a Notepad document; at this point, you can make any changes and then save the file by pressing Ctrl+S. The changes will immediately be reflected when you run the batch file.

Creating Batch Files

Batch files are normally created in notepad. Hence the simplest way is to open notepad and enter the commands required for the script. For this exercise, open notepad and enter the following statements.

Saving Batch Files

After your batch file is created, the next step is to save your batch file. Batch files have the extension of either .bat or .cmd. Some general rules to keep in mind when naming batch files −

  • Try to avoid spaces when naming batch files, it sometime creates issues when they are called from other scripts.

  • Don’t name them after common batch files which are available in the system such as ping.cmd. Skyrim disable bethesda intro 1.

The above screenshot shows how to save the batch file. When saving your batch file a few points to keep in mind.

  • Remember to put the .bat or .cmd at the end of the file name.
  • Choose the “Save as type” option as “All Files”.
  • Put the entire file name in quotes “”.

Executing Batch Files

Following are the steps to execute a batch file −

  • Step 1 − Open the command prompt (cmd.exe).

  • Step 2 − Go to the location where the .bat or .cmd file is stored.

  • Step 3 − Write the name of the file as shown in the following image and press the Enter button to execute the batch file.

Modifying Batch Files

Following are the steps for modifying an existing batch file.

  • Step 1 − Open windows explorer.

  • Step 2 − Go to the location where the .bat or .cmd file is stored.

  • Step 3 − Right-click the file and choose the “Edit” option from the context menu. The file will open in Notepad for further editing.

Even though batch files are like vintage when it comes to operating systems, they are one of the best ways to get things done. If you are in a kind of work which asks you run some pre-defined commands every day, the console windows are annoying especially when you are sure they are perfect, and will not make any mistake. In this guide, we will learn how you can run Batch Files silently in background mode and hide the Console Window.

File

Batch Script Comments

Run Batch Files silently on Windows

If you have a simple batch file that you want to run, you can create another batch file, and type in the command as below

There are two ways to execute it.

  • Run it from within the command prompt.
  • Create a shortcut on your desktop, and point it towards the bat file. Make sure to change the Properties of the shortcut as Start minimized.

Multiline Comment In Windows Batch File

Run batch files silently using a Scheduled Task

Comment

Windows has tons of features which are not used. The Task Scheduler is one of them. This feature allows you to run tasks in the background, periodically or every day. You can easily schedule a Batch file to run automatically using Scheduled Task with options available out of the box.

Here is the procedure to use it.

File
  • Type “Task Scheduler” in the Cortana box, and you should see the app listed. You can also choose to type “taskschd.msc” into the run prompt to open it.
  • On the last pane on the right-hand side, look for an option which says Create Basic Task. Click on it to open.
  • This launches a wizard which will ask you
    • Name of Task with a description
    • When do you want to start the task? You can choose between Daily, Weekly, Monthly, OneTime, When the computer starts and so on.
    • Next, select a program, and it will offer to choose a program or script, add arguments, start in details and so on.
  • Using this, you can add everything a bat file would need. In the end, select open properties window for further configuration.
  • In the properties window, you can choose to run the program even when is the user is logged out to make sure your program is working round the clock. Make sure to choose Hidden.
  • Add admin privilege permission by selecting the “Run with highest privileges” box. Click OK when done,
  • To test, the task works exactly as you need it to, right-click and selecting Run.

Run Batch Files silently & hide the console window using freeware

1] Hidden Start or HStart

It’s a lightweight command line utility that allows you to run console applications and batch files without any window, in the background. It can even handle UAC privilege elevation and also run multiple commands in parallel or in sync. The program offers a user interface which makes it easy to set things.

  • Drag, and drop the batch file on to the interface.
  • Choose options including hiding console windows, UAC, and so on.
  • You can also test it using test mode.
  • You can also add command line options if needed.
  • Directly created shortcut and auto start entry from the interface

You can download from here.

2] SilentCMD

Comment In Cmd Batch File

If you are comfortable with command line, i.e., typing and using a command prompt, SilentCMD offers tons of features and does our job as well. You can type in SilentCMD [path to .bat file] [arguments], and it gets the job done, quietly. Additionally, you can log in the output and errors into a text file.

You can download it from Github.

Make an executable file from a Batch Script

Executables are probably the best way to run batch files along with an option to hide your script from everyone else. There are many options available to make an executable file from a Batch Script and making an EXE is very simple. However, if your antivirus catches it, make sure to mark it safe as you are only using it for personal use.

Check out our detailed posts on the following subjects:

  • You can script batch programs and compile them into an .exe file with Batch Compiler.
  • Convert VBS to EXE using an Online tool or VBScript converter software.

Incidentally, Slimm Bat To Exe Converter offers three types of mode including express, windowless, and custom. You can download it from Softpedia.

These should be enough for you to create and run Batch Files silently on your Windows 10 PC. However, always test it before making them run quietly. You never want to lose your data because you didn’t test something properly.

TIP: Download this tool to quickly find & fix Windows errors automatically

Related Posts: