Creating scheduled task with .bat file. Delayed execution?

witcher

New member
Local time
10:39 AM
Messages
2
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.
Code:
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 Computer

OS
Windows 7 Ultimate 32bit
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
http://www.sevenforums.com/tutorials/67503-task-create-run-program-startup-log.html

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 Computer

OS
XP / Win7 x64 Pro
CPU
Intel Quad-Core Q9450 @ 3.2GHz
Motherboard
Asus P5-E
Memory
2x2GB GSkill DDR2
Graphics Card(s)
NVIDIA GeForce 8600 GTS (EVGA)
Monitor(s) Displays
Dell 2408WFP
Screen Resolution
1920x1200
Back
Top