I have a batch file that creates a scheduled task using schtasks like this:

schtasks /create /tn my_task_name 
                 /tr "...\my_path\my_task.bat"
                 /sc daily
                 /st 10:00:00 
                 /s \\my_computer_name 
                 /u my_username    
                 /p my_password

It works OK except the fact that when my_task.bat is executed - a new command line window is opened (and closed after execution).

I would like to avoid opening this new window (i.e. to run the task in quiet mode, in the background).

I thought to use

start /b ...\my_path\my_task.bat

but I don't know how, because since I have to call start from the batch file I need to precede it with cmd /c, which again causes the new window to open.

How could I solve this problem ?


I believe you're seeing the box because the account you set to run it as is your own. Try either of these:

1: Run the task as the user NT Authority\System

2: Make a new account and set the task to run with its credentials

| improve this answer | |
  • Could you add more details regarding the first option ? I don't really understand what Authority\System is. Thanks a lot ! – Misha Moroshko Oct 3 '10 at 5:44
  • @Misha: NT Authority\System is sort of an unadvertised system account that is responsible for running basic Windows services. Stuff that goes on all the time in many cases requires credentials and this is the way Windows handles it. Hit ctrl+alt+del, open task manager and tab to processes. You'll see many that are listed as user "System." That is NT Authority\System. When you go to set up the task using NT Authority\System, you'll not have to enter a password. Just leave that blank. – Flotsam N. Jetsam Oct 3 '10 at 21:06
  • I tried to set /u "NT Authority\System" /p "", and got the following error: ERROR: Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again... What am I doing wrong ? – Misha Moroshko Oct 4 '10 at 13:11
  • That sounds like you might have something in your batch file open under your own credentials already--perhaps a network drive. I would need to see your batch file (mytask.bat) to answer knowledgeably. – Flotsam N. Jetsam Oct 6 '10 at 2:06

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"
| improve this answer | |
  • So for some values of /RU the command-line window suppressed? Which ones? Is this documented somewhere? – martineau Nov 15 '12 at 17:49
  • Nope. I even didn't try to find. I found this workaround to solve my problem in some blog post and utilized it. – pmod Nov 15 '12 at 21:24
  • schtasks /create /? you get the help message and ref this docs.microsoft.com/en-us/windows-server/administration/… – Reegan Miranda Sep 20 '18 at 6:29

Perhaps using the AT command and don't include the /interactive switch.

AT \\my_computer_name 10:00AM /EVERY:M,T,W,Th,F,S,Su "...\my_path\my_task.bat"

If you need specific credentials for my_task.bat to run under, you will pobably have to put RUNAS in the command because I believe the command will run under the security context of the Schedule (Task Scheduler) service which is the "Local System" account. Adding the RUNAS command and switches before you BAT file should fix that.

| improve this answer | |

Finally, I used this code to solve the problem:

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "...\my_task.bat" & Chr(34), 0
Set WshShell = Nothing

saved it in run_my_task.vbs and scheduled run_my_task.vbs with schtasks as above.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.