I have a batch file, this batch file will not start automatically, it will only run when i double click on it.
Can I run the batch file in the background when I double click on it.
1] Hidden Start or HStartDrag, and drop the batch file onto 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.
Run batch file minimized from Windows Task Scheduler But if you want to run it minimized, then you have to make adjustments in the Actions tab. “^& exit” at the end is necessary to close the CMD window after the batch file is executed.
If you want to run additional commands while a previous command runs, you can run a command in the background. If you know you want to run a command in the background, type an ampersand (&) after the command as shown in the following example. The number that follows is the process id.
start /B command is the most given answer, but the command will be closed when the terminal closed. and then CTRL C, close the terminal, the command will continue to run in background.
Well, you can start it minimized with start
, if that is enough. Really hiding it is difficult (although I can think of an option right now).
Basically you need to determine whether the batch has been started by double-clicking it. You can do this by defining a special variable and look for it:
@echo off
if not defined FOO (
set FOO=1
start /min "" %~0
exit /b
)
rem here whatever you wanted to do originally in the batch
As long as the FOO
variable isn't defined (which is probably the default almost everywhere), this batch will launch itself minimized again, but with the variable defined first. Environments are passed to subprocesses, which is why this works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With