Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Is there a timer command in DOS?


(!)

flyboy320's Avatar
flyboy320 flyboy320 is offline
Member with 214 posts.
THREAD STARTER
 
Join Date: Dec 2001
17-Apr-2003, 06:48 PM #1
Is there a timer command in DOS?
I have a program running in dos that I would like to reboot once a day around 3:00am. I have a reboot.exe file that will do it for me, but I need a way to execute this at the prescribed time/interval.

Is there a way I could put this command in my autoexec.bat file and have it run reboot.exe after a certain amount of time has passed, or at a certain clock time?
Rockn's Avatar
Rockn Rockn is offline   Rockn has a birthday soon!
Computer Specs
Member with 21,189 posts.
 
Join Date: Jul 2001
Location: Somalia of the North, MN
Experience: Disenfranchised American
22-Apr-2003, 09:14 AM #2
You could write a simple timer app in Basic...batch files aren't meant to do this sort of thing. There are also tons of freeware timer applications on the net.
flyboy320's Avatar
flyboy320 flyboy320 is offline
Member with 214 posts.
THREAD STARTER
 
Join Date: Dec 2001
22-Apr-2003, 03:59 PM #3
Thanks I'll look around.......
Cosmic's Avatar
Senior Member with 1,298 posts.
 
Join Date: May 2003
05-May-2003, 02:47 PM #4
There is no Timer function as part of DOS.

You didn't say if you have the source code for the running program. If you do it is a piece of cake to add a TIMER check feature and reboot the machine within the running program at a time of your choosing. You didn't say if you have any programming abilities. Sounds like not, or you wouldn't be asking this question.

If you do not have the source code, the best way is to get a TSR utility running in background to do the job. This TSR utility would load via your normal boot sequence. It would continually check the TIMER and execute the reboot at your specified time. A very slick neat tailored solution. One thing to think about, you probably also need to set a flag, so the TSR knows the reboot has occured for a particular day.

I would do it such that control of the reboot time is set in a stored text file on the hard drive that the TSR checks to get its set point when loading up on the boot. Also would check to see if it already had rebooted for the day. Probably need to lock out any potential pumping or nasty type loops that can occur.

Flag can also be in the text file and reset at midnight each day by the TSR. Or you could store it in the IAC if you wanted to get real slick. Therefore only one reboot is sure to occur each day. Changing your setpoint would be very easy by just using any ASCII word processor to rewrite the setpoint value in the stored text file at any time of your choosing.

You need a tailored function type TSR written exactly for the job. Could be at a particular time, elapsed interval or whatever your lil heart desires. Couple ways to get one.

1. Write it yourself. PowerBasic language has the ability to easily make this type TSR running under DOS.

2. Check the PowerBasic programming websites and see if something like this already exists. These folks deal in source code, so anything found can be easily modified.

3. Beg someone at the PowerBasic programming websites to write you one or modify whatever found. Folks love these type requests.

4. In a real pinch, I might write you one. Don't know what month that might be.

Last edited by Cosmic; 07-May-2003 at 01:36 AM..
mole's Avatar
mole mole is offline
Member with 781 posts.
 
Join Date: Aug 1999
Location: Indian Head, MD
Experience: Advanced
13-May-2003, 08:55 PM #5
ping -n {x} 127.0.0.1 >nul

where x is the number of counts. If you make {x} = 10 it will be ca. 10 seconds.

mole

Last edited by mole; 13-May-2003 at 09:13 PM..
HexStar's Avatar
HexStar
Guest with n/a posts.
 
16-May-2003, 08:33 PM #6
There's no included timer command in DOS. But like everyone before me said, you can goto a place like download.com and search for that program as I am sure there are many of those types os apps availible for free.

HexStar
mole's Avatar
mole mole is offline
Member with 781 posts.
 
Join Date: Aug 1999
Location: Indian Head, MD
Experience: Advanced
16-May-2003, 09:24 PM #7
You can make a timer as I have shown.

mole
Cosmic's Avatar
Senior Member with 1,298 posts.
 
Join Date: May 2003
18-May-2003, 12:35 AM #8
This original post was incomplete. This points up the fact, that under DOS this problem is not easy, if you want to do it outside of the running program source code environment. Original poster Flyboy left us in the dark as to exact requirements.

If you have the source code, couple lines of code, not a problem.

If you want to attempt this exercise around the horn. BAT Files or whatever, TSR utility, or whatever you may have to bolt the requirement on to another compiled running DOS independent program, lots of luck.

Not really that easy to solve the original problem, never was, if you can not embed the solution in the running program source code.

You are faced with the problem of running an external requirement outside of the main running DOS program which is not a multi-tasking environment. The number of successful problem free examples is small.

You can do it exactly with a very well tailored TSR that does the TIMER check function, that continues to run in background and calls an On-Event task to interrupt the main program based on a large number of criteria. Not as simple as it sounds, unless you can embed in the source code of the main program.

You can do it under PowerBASIC, maybe under C, maybe under MASM, maybe under some very, very tricky BAT file scenario. The trick is going to be get it easy, small and problem free under any scenario. PowerBASIC can be done relatively easy but will not be a Tiny Model. Might work, might not, haven't attempted it.

The proof will be writing and posting a complete working program that can operate totally outside of any other independent running DOS program. I would be interested in seeing that; whatever method you might choose to present it as a complete solution. Please walk me thru each step.

Could definitely take your expertise to school for use in a number areas; I am interested in writing very large DOS programs where psuedo multi-tasking is desirable. Please be exact as to methodology and coding. Simple and foolproof is a big plus.
Cosmic's Avatar
Senior Member with 1,298 posts.
 
Join Date: May 2003
18-May-2003, 09:08 AM #9
Duh, after mulling over the original problem.

The simple solution is a hardware one. Use a plug in timer to turn off power to the PC at the desired time. When it turns back on do an auto-boot sequence where everything required loads and runs.

The very cheap common timers probably have a minimum Off internal in the several minutes range. The solid state ones might be more suitable if the Off Internal is critical.

Or as Murphy's Law might state:

All first solutions are wrong ...... The path of greatest resistance is the one usually taken
Rockn's Avatar
Rockn Rockn is offline   Rockn has a birthday soon!
Computer Specs
Member with 21,189 posts.
 
Join Date: Jul 2001
Location: Somalia of the North, MN
Experience: Disenfranchised American
18-May-2003, 03:44 PM #10
NOOOO....this is not a good way to shut down your PC and you will inevitabley screw up your OS doing it that way. If you have Win98 or better you can do it even easier for a shutdown. There is a very...very simple way to do this. Wrote back with your OS and I will show you how it's done using nothing more than Windoze funtionality.
__________________
My no line signature
a
a
bobpaul's Avatar
bobpaul bobpaul is offline
Junior Member with 4 posts.
 
Join Date: Aug 2003
04-Aug-2003, 03:28 PM #11
Pay attention...
No, it's not a good way to restart windows, linux, mac os, or unix by disconnecting the power, but for the most part, dos doesn't care. Actually, that is the only way to shutdown a dos machine, so it won't matter. In Windows it isn't even that big of a deal. But you're right, the prefered method to shutdown windows is with the proper command and one could use the Windows Scheduling agent in Win98+ or download a scheduling App for Win95 to shut the system down properly at a specified time. Since he said in the initial post that he's using dos, though, there is no scheduling agent.

A timer on the power supply will be fine. Just make sure that if you have an ATX power supply the bios set to turn the computer on after a power failure. Other wise the system will remain off. If you have an AT power supply, this, of course, will not be a problem.
bobpaul's Avatar
bobpaul bobpaul is offline
Junior Member with 4 posts.
 
Join Date: Aug 2003
04-Aug-2003, 03:50 PM #12
Also, run a search for doat.zip on the internet

This program can be placed in the autoexec.bat file and will run a program at a specified time, ie it can run reboot.exe everyday at 3am.

ex: at 3:00 c:\reboot.exe
top_gizmo's Avatar
top_gizmo top_gizmo is offline
Member with 152 posts.
 
Join Date: Jun 2003
Location: Lebanon, MO
04-Aug-2003, 09:24 PM #13
Ok, we know it is not good to reboot your computer like this...

So, the problem is that you want to kill that application at 3:00

Goto, www.hiddensoft.com and get a copy of Autoit 2.64

This will let you write a easy script to kill the application via Task Manager instead of rebooting like this.

Alternativly, you could write a shutdown or reboot script also.
bobpaul's Avatar
bobpaul bobpaul is offline
Junior Member with 4 posts.
 
Join Date: Aug 2003
05-Aug-2003, 01:40 AM #14
But most important is that he's using Dos, not windows. That's why he was asking about bat files. Read the origional post
prakka's Avatar
prakka prakka is offline
Junior Member with 1 posts.
 
Join Date: Dec 2005
Experience: Advanced
08-Dec-2005, 07:54 AM #15
Smile if command
Wouldn't it be just as easy to make an program (asdf.bat) with the IF command that checks for the local time with a specific time (in this case 03:00 am). And when that is, you run your reboot.bat thingy. You will also need to put asdf.bat in the autoexec configure file to auto start-up when the pc starts.
It isn't really that hard, just look on a search engine for batch commands.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑