How to start a batch file minimized with task scheduler in Windows 8? - %comspec% method not working anymore after Windows 7
Solution 1
The start command needs the leading ""
quotes to disable the title feature. Try scheduling this:
%comspec% /c start "" /min "C:\Scripts\Destination_inbound_ftp5.bat" ^& exit
Solution 2
Assuming Windows 8 is the same as Windows 7, an "exit" is only going to exit the batch file (which it is going to do anyway).
You need to add the exit code like this:
Under "Program/Script":
CMD (or command.exe, or %comspec%)
Under "Arguments:
/c start "Title" /min "C:\Scripts\Destination_inbound_ftp5.bat" ^& exit
Solution 3
I didn't like seeing the command window pop up and then disappear so here is another solution from https://ss64.com/vb/run.html ...
First create invisible.vbs
with this single line of text:
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
Next and finally, launch your cmd or batch file via:
%SystemRoot%\system32\wscript.exe "invisible.vbs" "myscript.cmd" //nologo
Ta da! Scripting of this sort has been built into Windows for a long time. If you're curious, do a web search for "WSH" (windows scripting host). You can even write such scripts in dialect of JavaScript called JScript.
Solution 4
Another possibility: a small freeware program named CMDH, that simply runs the requested orders in background. For example:
cmdh MyScript.cmd
No need to add "exit" to the script. Tested working in Windows XP SP3, and there is no reason it should fail on Windows 8.
Solution 5
Here's a solution from https://ss64.com/vb/run.html that will run a batch file in a minimized window. Unlike the other solutions that use the start
command with /min
, this one will not flash a new window onto your screen or interrupt full-screen activities. It does, however, steal focus. I don't know how to avoid that.
First create a file named run_minimized.vbs
with this single line of text:
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 2, False
Next, create your Task Scheduler task with an action to start the program wscript.exe
with these arguments:
"c:\path\run_minimized.vbs" "c:\path\my script.bat"
Change the paths as necessary to specify the locations of the two files.
There is no simple way to pass arguments from Task Scheduler to the batch file while also preserving spaces and quotation marks, because wscript strips quotation marks from its arguments. The simplest way to handle arguments with spaces would be to put the entire batch file command into the vbs:
CreateObject("Wscript.Shell").Run """c:\path\my script.bat"" ""arg 1"" arg2", 2, False
Note the use of quotation marks. There's one pair of quotation marks "
enclosing the entire command string, and a pair of adjacent quote characters ""
every place you'd use a normal quotation mark in a command line.

user225479
Updated on September 10, 2021Comments
-
user225479 over 1 year
After Windows XP, I always use the trick below to start batch files minimized with Windows Task Manager.
From http://www.pcreview.co.uk/forums/running-bat-files-minimized-scheduler-t2125918.html:
"prequisite: all your batch files have an exit-command to finish the actions off. If you do not exit, you will end with a command prompt blinking.
This is what I keep using:
%comspec% /c start /min "C:\Scripts\Destination_inbound_ftp5.bat"
When you save this in the properties, you will get a follow-up dialogue asking you if you meant all this to be parameters or not. Answer NO and the task will be saved as you would expect.
I also read the Stack Overflow question “start %comspec% /c script.cmd” vs “start cmd /C second.cmd script.cmd”, which made me replace the "%comspec%" statement with "C:\Windows\system32\cmd.exe", but that did not change anything either.
The problem is that now, instead of a minimized running bat file, I end up with just a command prompt, minimized but without any of the batch commands executed. The task scheduler status remains "running" :(
How do I get this done on Windows 8 (64-bit)? Preferrable with old-school batch commands instead of PowerShell (or worse ;p)
-
Nicolai Schlenzig over 8 yearsRemember to add an exit code for the batch file, or the Command Prompt will stay opened after successful run.
-
Synetech over 7 yearsThis won't work, it will still create a console window which flashes up (and steals input focus) for a moment. It doesn't create a console window for the batch file, but it does for the
cmd
process (and thestart
command), so this isn't the same as running it in the background (i.e., no visual indication at all). -
foxidrive over 7 years@Synetech Thanks for your comment but it wasn't running at all for the OP due to the title requirement of the start command - and
"(i.e., no visual indication at all)."
isn't asked in the question. -
user18099 about 7 yearsSee RationalRabbit's answer for making sure windows don't stack up (add "^& exit" to command parameters.
-
fantabolous over 6 yearsLinked CMDH server is down and I can't find any other links to CMDH in google. Perhaps not too well supported.
-
Sopalajo de Arrierez over 6 yearsIndeed, @fantabolous , the full site seems to be dead. I could upload it somewhere, but I think links to Google Drive or similar storage sites are not allowed by rules. Could someone please tell us about some allowed method to upload a file?
-
Vlastimil Ovčáčík over 5 yearsThis is probably better variant of
cmd /c start "" /min cmd /c batch.bat
. -
cdlvcdlv over 5 yearsCan you add parameters to
myscript.cmd
if needed? -
Rogério Dec over 4 yearsIn my case, with Windows 10, I had to add
%comspec%
at the beginning to this example work. -
Andre over 4 yearsNice. This checkbox is somewhat... hidden. (Not really, but rather inconspicuous.)
-
Admin about 4 yearsin addition to 'Hidden', also click 'Run whether user is logged on or not' to make the task run silently in the background.
-
rayzinnz over 3 yearsThis doesn't work with my testing, and the cmd window still pops up.
-
maxeh over 3 yearsThis requires an extra file but is the best solution!
-
tim11g almost 3 yearsBy the name, you would assume it would hide the window, but I can confirm it does not work for Windows Server 2008r2 either.
-
Jimadine almost 3 yearsAs per superuser.com/a/478066, ticking the 'Hidden' checkbox does not hide or minimize the program. Instead it hides the task from Task Scheduler's list of tasks. See also: Task Scheduler 'View' menu > 'Show hidden tasks'.
-
mmortal03 almost 3 yearsNeil's solution makes the command window that is being run completely invisible (hidden). If you just want to have it start minimized, change the parameter just before "False" to 7 instead of 0. Also see "Settings for intWindowStyle" at his provided link above for more options.
-
Jacek Krawczyk over 2 yearsI have found it on this site: forum.tuts4you.com/files/file/…
-
TheWalkingData over 2 yearsAfter trying Powershell, Python, and simple batch file, this is the solution I found that worked. Its quite interesting that you simply just can't run a background Powershell script without a window flashing. Its quite mind boggling, especially since Powershell is quite handy. I'm sure there are other ways, but this simple way worked for me. I was trying to do SCP, and it worked with this solution. I know that you can set Task Scheduler to run a Powershell script via "SYSTEM" user and it won't flash a PS window, I have some of those scripts. But for SCP I had to use my current user.