Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Creating scheduled task with .bat file. Delayed execution?

14 Sep 2012   #1

Windows 7 Ultimate 32bit
Creating scheduled task with .bat file. Delayed execution?

I know how to create scheduled task from .bat file. But if the PC is turned off, i want it to run first time someone logs on.
SchTasks /Create /SC MONTHLY /D 15 /TN “My Task” /TR “C:RunMe.bat” /ST 14:00
what should i add to this code to make it run if the user opens his pc at 16:00?

Any idea is appreciated.

My System SpecsSystem Spec

14 Sep 2012   #2

XP / Win7 x64 Pro

So, the way I knew how to do this prior to know was via the Scheduled Tasks GUI, as noted in step #18 below:

Run Task as soon as possible after a scheduled start is missed
Task - Create to Run a Program at Startup and Log On

When trying to figure out how to do this via the command line, I simply don't think it's possible to specify conditions via the command line. However, this forced me to think outside the box and I think I've figured a way to do this.

1) Create the scheduled task you'd like to run, with the specified conditions as noted in step #18 above, and give it some name. We'll call it "Task1".
2) Via the command line, export that scheduled task to an XML file:

schtasks /query /xml /tn Task1 > C:\Temp\Tasks\Task1.xml

3) Then, in your batch file, create the scheduled task from that XML file (which should hopefully include the conditions you've set):

schtasks /CREATE /TN Task1 /XML C:\Temp\Tasks\Task1.xml

See if that works.
My System SpecsSystem Spec

 Creating scheduled task with .bat file. Delayed execution?

Thread Tools

Similar help and support threads
Thread Forum
Creating scheduled task for SyncToy 2.1?
I am trying to create a scheduled task for SyncToy 2.1 using the Win 7 task scheduler and the instructions included in the Help section of Synctoy. It should be simple except it doesn't work. Everything goes well until I place the path/script in "conditions". The instructions state This is what I...
Scheduled Task history indicates task completed successfully but....
Hi, New here. I'm using a Scheduled Task to fire a very simple bat file that pulls, compresses and pushes a set of files to a different network directory. The bat file runs fine manually. On a networked desktop I have set up the task to run at about 5am est (waking the machine), as highest...
Performance & Maintenance
Edit a scheduled task
I want to edit a scheduled task but can’t identify which one due to their mysterious names. How can I determine the right one?
General Discussion
Need help creating a task scheduler task to move files over a network.
Hello everyone, I need to have a task run that will move the contents of a folder from one computer to another over my home LAN. Files get downloaded during the night on one computer and then need to be transfered to another. Usually I am doing this by hand, but then though maybe I could get...
General Discussion
Scheduled Task not running
Scheduled Task not running when "run whether user is logged on or not" option is selected? Is this an issue/bug in windows 7?
General Discussion
Creating Scheduled Backups of Outlook Contacts
In Outlook I know how to archive folders and set how often these should be backed up. This backup can then be backed up so in the event of me losing data any saved emails etc. can be recovered. The problem I am having is archiving and then backing up my contacts in Outlook. I know how to...
Microsoft Office

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 21:20.

Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App