How to execute a scheduled task with "schtasks" without opening a new command line window?

You can use the Windows Shell Scripting extensions to execute a batch file in invisible mode.

  • Create a plain text file and name it <scriptname>.vbs

  • Paste the following code in the .vbs file

      Set WshShell = CreateObject("WScript.Shell") 
      WshShell.Run chr(34) & "C:\Batch Files\syncfiles.bat" & Chr(34), 0
      Set WshShell = Nothing
    
  • Change the name and path of you batch file according to your need

  • Save the .vbs file and schedule the same in schtasks


You can do this by specifying /RU option for schtasks. This option

specifies the user account (user context) under which the task runs. For the system account, valid values are "", "NT AUTHORITY\SYSTEM" or "SYSTEM".

And thus, try this

schtasks /create /tn my_task_name 
                  ....
                 /st 10:00:00 
                 /ru "SYSTEM"
                 ....