Can not schedule a batch file to run at startup

0

I'm trying to schedule a batch file to run at start up. Here is my command:

schtasks /create /tn test /tr c:\simple.bat /sc onstart

simple.bat only writes the current time to a file:

time /t > now.txt

The task is created without issues, I see it when listing tasks via schtasks (it has status ready) and in the Task Scheduler Library in windows.

When running the batch file manually, everything is fine. However, when restarting, I see the batch is not running (no output file with the updated time) and when looking at the output of schtasks I see the status has changed to "Could not start":

TaskName                                 Next Run Time          Status         
======================================== ====================== ===============
test                                     N/A                    Could not start

Any ideas? Thanks.

omer bach

Posted 2014-05-05T06:48:14.823

Reputation: 113

Question was closed 2014-05-06T11:15:06.560

Maybe missing security context? How can I script schtasks so it doesn't need a password?

– bummi – 2014-05-05T10:11:22.557

Just wondering, is there a reason you need to use the task scheduler instead of the startup folder? – daraos – 2014-05-05T10:46:17.097

Answers

2

Are you using Windows 7? I had a similar problem with a script that worked fine if launched from the command line, but that would not run on schedule. The answer, in my case, was very trivial: there was a box to be ticked valid, at the bottom of the window, where you could specify that the task schedule was active or not. May this simply be the case for your too?


Please Check the Properties of a given task, then look for the "triggers" tab and make sure that the tick box at the bottom of the "triggers" window is enabled. Sorry I cannot post pictures yet.

massimopinto

Posted 2014-05-05T06:48:14.823

Reputation: 23

I'm using win7. can you please specify the location of that checkbox. – omer bach – 2014-05-05T08:39:09.797

0

You can convert this bat file to exe,and then you can schedule it :) This is a freeware software called Advanced Bat to exe that can convert bat file to a exe :)

SSAURABHH

Posted 2014-05-05T06:48:14.823

Reputation: 435