Results 1 to 8 of 8

Thread: Timer Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    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.

  2. #2
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Location
    Toronto, Canada
    Posts
    357

    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.

  4. #4
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    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.
    CS

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Timer Question

    Quote 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.

  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Timer Question

    Sorry. I have NoteMe Syndrome.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    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
  •  



Click Here to Expand Forum to Full Width