avoiding console window display when scheduled task runs batch file

4

I have a small batch file which xcopies some files from one folder to another which I've scheduled (via windows scheduled tasks) to run every 1 hour:

@echo off
xcopy c:\foo c:\bar /E /C /F /Y

Since this is my workstation, I'm most probably doing work when the task executes, and then the black dos console window is displayed (lasts 2-3 seconds) and steals window focus.

I don't wish to see the files copied and of course the batch file does not ask for any user input. Is there a way to avoid displaying the console completely?

cherouvim

Posted 2010-05-05T10:47:20.440

Reputation: 819

1

Same question & Answers on ServerFault: Run a .bat file in a scheduled task without a window

– geek1983 – 2010-05-05T12:54:06.073

1

Possible duplicate of Run a batch file in a completely hidden way

– Scott – 2018-09-01T16:43:03.213

More preferable answer to the one Oliver gave http://stackoverflow.com/questions/6568736/how-do-i-set-a-windows-scheduled-task-to-run-in-the-background

– Efekt – 2014-05-10T05:45:38.253

Answers

1

Check the "Run whether user is logged on or not" radio button. Even if you select the same user you're logged in as, it will start and run silently, not stealing mouse or keyboard focus. Source

user417541

Posted 2010-05-05T10:47:20.440

Reputation:

It does run silently, but it also runs with a delay (I measured 18 seconds once) after the triggering event. – Alexander Pruss – 2019-07-23T13:40:06.573

-1

You have to pass through START and CMD commands:

start "" /B "cmd /k "xcopy c:\foo c:\bar /E /C /F /Y""

Option /B tells the command interpreter not to create a new window.

Gabriele Bertolucci

Posted 2010-05-05T10:47:20.440

Reputation: 17

But won’t it still display a Command Prompt window for the START command itself?It has been reported that this does not work.

– Scott – 2018-09-01T16:14:40.023