5

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?

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306
cherouvim
  • 1,199
  • 4
  • 11
  • 26
  • 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 May 10 '14 at 05:45
  • 1
    Same question & Answers on ServerFault: [Run a .bat file in a scheduled task without a window](http://serverfault.com/questions/9038/run-a-bat-file-in-a-scheduled-task-without-a-window) – geek1983 May 05 '10 at 12:54
  • 1
    Possible duplicate of [Run a batch file in a completely hidden way](https://superuser.com/questions/62525/run-a-batch-file-in-a-completely-hidden-way) – Scott - Слава Україні Sep 01 '18 at 16:43

2 Answers2

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

-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.