- 1 year ago
executing a .bat file in background and daemon mode
To execute a .bat file in the background and daemon mode on Windows, you can use the start
command along with the /B
and /MIN
options. The /B
option runs the command without opening a new window, and the /MIN
option starts the new window minimized. Here's the command you can use:
batchstart /B /MIN your_script.bat
This will run the .bat file in the background and in daemon mode. The batch script will execute without opening a visible window, and it will continue running until it completes or is terminated.
If you want to hide the window entirely and not have it show up minimized, you can use a VBScript to execute the .bat file. Create a new file with a .vbs extension (e.g., hidden.vbs
) and add the following code:
vbscriptSet objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "your_script.bat", 0, False
Replace your_script.bat
with the path to your actual .bat file. Now, to run the batch file in the background and completely hide the window, execute the VBScript file:
batchstart /B wscript.exe "hidden.vbs"
This will run the VBScript in the background, and the .bat file will be executed without any visible window.
Keep in mind that while these methods hide the window, the batch script will still be running in the background, and you can terminate it through Task Manager or other means if needed.