A program that runs a batch file (.bat or .cmd) in minimized mode.

This time,Batch fileWe will introduce "CMD_MinRun.exe", a program that runs the command prompt window that appears when you run ".bat" or ".cmd" in a minimized or hidden state.

Please use this when you want to run a batch file in the background.

table of contents

How "CMD_MinRun.exe" works and how to use it

How it works

  • "CMD_MinRun.exe" cannot be executed directly
  • extensionYou cannot run files other than ".bat" or ".cmd"

When the program is executed, it reads the command line arguments passed to the program, and if the number of parameters is "0" (no arguments), it determines that it was executed directly, displays a message, and terminates the program.

This program cannot be executed directly.
This program cannot be executed directly.

If the number of parameters is not "0" (if there are arguments), a regular expression is used to determine whether the argument file has the extension ".bat" or ".cmd", and if the extension is different, a message is displayed and the program is terminated.

This program cannot be executed unless the extension is ".bat" or ".cmd".
This program cannot be executed unless the extension is ".bat" or ".cmd".

If the number of parameters is not "0" and the extension is ".bat" or ".cmd", the batch file will be executed minimized or hidden.

*The program will terminate immediately after executing the batch file.

How To Use

1. Left-click the batch file and hold it down, then move it over "CMD_MinRun.exe" and release the left-click (drag and drop).

2. Execute the command from Run, Command Prompt, Task Scheduler, etc.

For example, if you want to run "Bacup.bat" in the Documents folder, write the path to "CMD_MinRun.exe", a space, and the batch file you want to run.

"%USERPROFILE%\Documents\CMD_MinRun.exe" "%USERPROFILE%\Documents\Bacup.bat"
command prompt
command prompt

The location of "CMD_MinRun.exe" does not have to be the same as the batch file, but be sure to enclose each path in double quotes.

When registering in the Task Scheduler, specify the path to "CMD_MinRun.exe" in "Program/script (P):" and the path to the batch file in "Add arguments (optional) (A):".

task Scheduler
task Scheduler

For example, if you want to back up some files periodically in the background, this is useful as it doesn't get in the way and you don't want the command prompt window to appear while you're working.

2024/04/26 Ver 1.0.0.1 :

Added the option "/h". Using the option "/h" allows you to run the program in a hidden window.

Example:

"%USERPROFILE%\Documents\CMD_MinRun.exe" "%USERPROFILE%\Documents\Edge_Profile_Bacup.bat" /h

Source code and download for "CMD_MinRun.exe"

Source code (Ver 1.0.0.0)

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=CMD_MinRun.exe
#AutoIt3Wrapper_Res_Description=バッチファイルを最小化した状態で実行します。
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_ProductName=CMD_MinRun
#AutoIt3Wrapper_Res_ProductVersion=1.0
#AutoIt3Wrapper_Res_CompanyName=©2024 wenbang https://windows-waza.com/
#AutoIt3Wrapper_Res_LegalCopyright=©2024 wenbang https://windows-waza.com/
#AutoIt3Wrapper_Res_LegalTradeMarks=CMD_MinRun.exe
#AutoIt3Wrapper_Res_Language=1041
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

If $CmdLine[0] = 0 Then Exit MsgBox(16 + 262144, "エラー", "このプログラムは直接実行することはできません。", 0)

If StringRegExp($CmdLine[1], "\.bat$|\.cmd$", 0) Then
    Run(@ComSpec & ' /c "' & $CmdLine[1] & '"', "", @SW_MINIMIZE)
Else
    Exit MsgBox(16 + 262144, "エラー", "このプログラムは、拡張子が「.bat」または「.cmd」以外は実行できません。", 0)
EndIf

Source code explanation

In Autoit, $CmdLine contains the command line arguments passed to the program.

$CmdLine[0] is assigned the number of parameters, and $CmdLine[1] is assigned the path to the program executed by "CMD_MinRun.exe".

The following code checks the number of parameters, and if the number is "0", the program terminates and displays a message box saying "This program cannot be executed directly."

If $CmdLine[0] = 0 Then Exit MsgBox(16 + 262144, "エラー", "このプログラムは直接実行することはできません。", 0)

The following code checks whether the extension (last four characters) of the path of the file executed by "CMD_MinRun.exe" is ".bat" or ".cmd".Regular expressionChecking with (StringRegExp).

If the extension is ".bat" or ".cmd", run the batch file minimized.

If the extension is different, the program will terminate and a message box will appear stating "This program cannot be run unless it has the extension '.bat' or '.cmd'."

If StringRegExp($CmdLine[1], "\.bat$|\.cmd$", 0) Then
    Run(@ComSpec & ' /c "' & $CmdLine[1] & '"', "", @SW_MINIMIZE)
Else
    Exit MsgBox(16 + 262144, "エラー", "このプログラムは、拡張子が「.bat」または「.cmd」以外は実行できません。", 0)
EndIf

materials

All software distributed on this site has been virus-checked with ESET Internet Security, but because it is a personal development project, it does not have a genuine Microsoft digital signature. Therefore, the following warning may be displayed in some environments when running it for the first time.

  • Windows warning: "Windows protected your PCIf you see the message, please click "More Information" and then select "Run".
  • Security software warning: After updating definition files for ESET and other programs, it may be mistakenly detected as a "Suspicious Object," but it is not a dangerous program.

Please be sure to check the following page before use for information on how to verify the authenticity of a file using its hash value (SHA256), as well as for disclaimers and terms of use.

* Regarding use of the software (please read carefully)

2024/04/26 Ver 1.0.0.1:

  • Add option "/h": Using the "/h" option allows you to run the program with the window hidden.

2026/05/19 Ver 1.0.0.2:

  • [Bug Fix] Support for simultaneous processing of multiple files: Fixed an issue where, when passing multiple files or arguments, the second and subsequent data items were ignored. This ensures that all arguments are correctly passed to the batch file, even when dragging and dropping multiple files.
  • [Bug Fix] Fixed execution error with paths containing spaces: This update fixes an issue where, if the path or arguments contained spaces, the path would be truncated due to the specifications of cmd.exe in Windows, preventing the program from executing correctly.
  • [Improved functionality] The /h option has been made more flexible in its detection: We've improved the internal detection logic for the /h option, which is used to run batch files invisibly, so that it is correctly recognized regardless of its position in the arguments and switches to invisible mode.

Target file: "CMD_MinRun.exe" (Ver 1.0.0.1)
ハッシュ値(SHA256):63fe1930ece344a242dce4098ff1bda4fa5f360693d70cd1639d555145e49c2e

Target file: "CMD_MinRun.exe" (Ver 1.0.0.2)
ハッシュ値(SHA256):192ccb85d4ed7513eab4528c01e421b0b534fde83ba6fcf97a1c023d1fe388f9

CMD_MinRun_v1.0.0.2.zip

How to automatically back up your Microsoft Edge profile on a regular basis

If you found this article helpful, please share it on social media.

Person who wrote this article

Driven by questions arising from my daily PC use and the desire to "do more," I have been pursuing self-study in Windows since around 2008. I am sharing the "aha!" techniques and solutions I discovered through trial and error with the sole purpose of helping you in your PC life.

View profile

Comment:

To comment

[About submissions]
We welcome any questions or information regarding the content of the article.
However, please note that content unrelated to the purpose of the article, criticism of specific individuals or organizations, offensive language,Inappropriate wordsComments containing the above may be deleted or made private without notice at the discretion of the administrator.
Please note that spam may be automatically deleted by anti-spam measures.

CAPTCHA


table of contents