Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start a batch file minimized with task scheduler in Windows 8? - %comspec% method not working anymore after Windows 7

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)

like image 342
user225479 Avatar asked Sep 18 '13 19:09

user225479


People also ask

How do I run a batch file minimized in Task Scheduler?

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.

How do I start a program minimized in Task Scheduler?

Here's how: Right-click the program icon you have pinned to your Windows taskbar. Right-click once more, this time on the program, and select Properties. Change the Run command to Minimized and click OK.

How do I schedule a batch file in Windows 7?

Launch the Task Scheduler by clicking Start, typing Task in the search box, and selecting Task Scheduler from the search results. You can also access the Task Scheduler from the Administrative Tools menu. When Task Scheduler launches, select Create Basic Task from the Action pane on the right of the window.


2 Answers

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 
like image 176
foxidrive Avatar answered Sep 19 '22 20:09

foxidrive


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 
like image 43
RationalRabbit Avatar answered Sep 18 '22 20:09

RationalRabbit