|
-
Apr 8th, 2006, 01:41 PM
#1
Thread Starter
Hyperactive Member
Timer Question
I am quite not good at using timers. What I wish to do is that I want create a program for turning of my computer for a certain period of time.
The scenario: I am downloading a huge file and I will not be home when it is finished downloading. So I want to create a program that will turn the computer off after 7 hours. Could someone help me?
Hey... If you found this post helpful please rate it.

-
Apr 8th, 2006, 01:53 PM
#2
Frenzied Member
Re: Timer Question
Khanjan a2k:
I know that this is not the kind of "timer" you are talking about, but it works great.
I wanted to do the samething and was also going to write a simple program to do this. However, I solved my problem by buying a simple $15.00 electronic timer at my local hardware store. I just plug my computer into the timer and plug the timer into the wall outlet. It works great and is much easier to change the time setting than having to go into a program and change the code to adjust the time.
Just a suggestion.
Good Luck
-
Apr 8th, 2006, 02:04 PM
#3
Thread Starter
Hyperactive Member
Re: Timer Question
Yeah, but since I can just create a program myself, I just want to find out how to use the timer control so that I can turn my computer off.
Hey... If you found this post helpful please rate it.

-
Apr 8th, 2006, 02:05 PM
#4
Re: Timer Question
Hi,
There is a dos command shutdown.exe will do that. Here is the commandline parameters:
Code:
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)
Use the shell functions to run this command from visual basic.
No need to use any timer control or any other third party softwares.
-
Apr 8th, 2006, 08:33 PM
#5
Re: Timer Question
To shutdown the computer at specified time, you can add a timer with 1 second interval. When current time matches the predefined time, turnoff the computer.
To get current time, use Now or Time. To check the time diference, use DateDiff function. To shutdown the computer, use ExitWindowsEx API. (You'll need to set appropriate permission in WinNTx systems.)
Alternately, to wakeup the computer at specified time, see my codebank submission. It may help.
Last edited by iPrank; Apr 9th, 2006 at 12:18 PM.
Reason: NoteMe Syndrome
-
Apr 8th, 2006, 10:42 PM
#6
Re: Timer Question
 Originally Posted by iPrank
To check the time diference, use DataDiff function.
DateDiff. I make that typo in the other direction all the time. I get date from a database. 
Between us we're a pretty good typist.
-
Apr 9th, 2006, 12:19 PM
#7
Re: Timer Question
Sorry. I have NoteMe Syndrome.
-
Apr 9th, 2006, 04:01 PM
#8
Re: Timer Question
Why bother with all the hassles? Just enter a Scheduled event to run the shutdown command 7 hours (or whenever) you want. See DOS AT /?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|