3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Is there a batch script that you can compile and have it run a command when a date/time is met.

I need a batch script that can: run in the backround when a certain date/time is reached execute a command Any help would be much appreciated. Private Message me Thanks dla888

13 answers
sort by: active | newest | oldest
Oct 20, 2009. 11:25 AMdasdre says:
Use this: <br /> @echo off<br /> :X<br /> if date==*your date here* *what you wanna do here*<br /> goto X<br /> <br /> save as whatyouwannauseasname.bat & put on startup<br /> DONE!<br />
Jun 10, 2009. 4:32 PMJenniC says:

The following biterscripting ( http://www.biterscripting.com ) batch script will do it. It will wait until it is June 11, 1009, 2:30 pm, then execute command "command".

while ( gettime() < "20090611143000")
sleep(60)
system "command"

Jenni
Jun 9, 2009. 12:13 AMAndyGadget says:
As a straight batch file, Windows gives you Too Much Information to do this . . .
Type in 'echo %date%' (without the quotes) and press Enter.
The date is displayed.
Now type in '%time%'
The time is displayed, but to a resolution of 1/1000th of a second!
You can use comparison operators in batch files, but there's no way (that I know of) of masking out part of the %time% string so you could compare, but you'd probably miss the event!

A better way of doing what you want is to use the built-in scheduler. To get to this, go to Control Panel then Scheduled Tasks. You can run any program you like (including batch files) from there.

You can also set up the scheduler from a batch file, which is closer to what you're after. It can run once, or every hour, week etc. You need to use the AT command, so your set-up batch would be something like :
AT 14:30 NEXT:25 C:\MYBATCH
This would run your batch file (mybatch) at 2:20 PM on the 25th of the month.
Jun 9, 2009. 8:19 PMPadlock says:
there's no way (that I know of) of masking out part of the %time% string
try echo %time:~0,8% or echo %time:~0,5%.
Jun 10, 2009. 11:07 AMAndyGadget says:
Wow! Live and learn! As it's part of the TIME system variable, is this an undocumented parameter or can it be used more widely?
Jun 10, 2009. 11:32 AMPadlock says:
It can be used with any variable, with the exception of %1, %2, etcetera.
Also try ...
set variable=123abc
echo %variable:abc=456%
Jun 10, 2009. 2:34 PMAndyGadget says:
You're a scary thirteen year old, Padlock ;¬)
Many thanks - I'll be using that in the future.
Jun 9, 2009. 12:17 AMAndyGadget says:
I've just seen your avatar - We are talking Windows here aren't we ? (not Linux ;¬)
Jun 9, 2009. 1:09 PMAndyGadget says:
I started wayyyyy back with a couple of the first (pre IBM) desktop computers and then onto my first PC (an XT) with MSDOS, and started on Windows at version 3.0. I've played with a few flavours of Linux (Puppy, Mint) but I have so many Windows applications and utilities for doing the things I do that it would take months to get anything equivalent going in Linux - if at all. Linux remains a bit of fun for me (but it has helped me on more than once occasion by booting up from a memory stick and accessing hard drives which Windows had given up on.)
Jun 8, 2009. 11:46 PMlemonie says:
Batch files have their limitations you know. A batch file is a batch of commands, it's not a programming language. At some point you'll have to stop asking "how do I do this with a batch?" and just ask "how do I do this?" Visual Basic? L
Jun 9, 2009. 1:24 PMlemonie says:
Best wishes for it, I know there's quite a lot of VB resources about. L

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!