Power Switch for computer

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
Mike
Posts: 1813
Joined: Thu Mar 06, 2003 1:01 am
Location: Illinois
Contact:

Power Switch for computer

Post by Mike » Thu Aug 12, 2004 7:09 pm

Does anybody know how to build a power off switch that will work on a computer? I have a P233 computer running as a server for my media files. It turns on at 6:30 in the morning, and off at 10:30 at night. Sometimes I don't need it, so I might as well shut it off. Is there a way to build a simple device to plug into the serial port or something to tell win 2k pro to shut down?<p>I would use the power button on the computer, but it doesn't support that feature to shut down when pressed.<p>Thanks!

hp
Posts: 245
Joined: Sat Aug 09, 2003 1:01 am
Location: Friendswood, TX
Contact:

Re: Power Switch for computer

Post by hp » Thu Aug 12, 2004 7:55 pm

Just write a program in vb to shutdown the computer when a pin on the serial port is driven high / low. <p>VB can read the rts / cts pin statuses using the mscomm control (well at least I think it can).<p>You can shutdown the computer using an API call or shell a 'shutdown' command. Maybe using the -f flag to force the shutdown and close any program.<p>Harrison

User avatar
haklesup
Posts: 3046
Joined: Thu Aug 01, 2002 1:01 am
Location: San Jose CA
Contact:

Re: Power Switch for computer

Post by haklesup » Fri Aug 13, 2004 11:53 am

If you just want something to pull the plug at the appointed time, just about any light timer will do but that is a bad way to power off a PC. <p>You should search the download libraries of the web for an application that can do it for you if you don't want to write one yourself.<p>Check your BIOS settings, you should be able to configure what the power button does. Options are isually instant off and 5 second delay. Windows also has options as to what happens when the power button is pushed, options are to bring up the shutdown menu or to hibernate.<p>Setting your PC to hibernate might be just as good as off and it starts up faster later too

Mike
Posts: 1813
Joined: Thu Mar 06, 2003 1:01 am
Location: Illinois
Contact:

Re: Power Switch for computer

Post by Mike » Fri Aug 13, 2004 7:31 pm

I've tried the BIOS settings and stuff buy nothing worked. windows seems to ignore my settings. So, how would I go about building that thing?

dyarker
Posts: 1752
Joined: Fri Aug 22, 2003 1:01 am
Location: Izmir, Turkiye; from Rochester, NY
Contact:

Re: Power Switch for computer

Post by dyarker » Fri Aug 13, 2004 9:32 pm

Plugging the PC's power cord into a timer would certainly do the job. Don't! Windows isn't given a chance to stop programs, close files, etc.<p>You need a program that that calls API function-
bool ExitWindowsEx(EWX_POWEROFF, reason)
"reason" must be non-zero to properly close running programs. SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED is a good one. It can be written in VB. (I got that from Windows PSDK, you can probably find a VB example at [url=http://www.microsoft.com)]www.microsoft.com)[/url]<p>That program could monitor the serial port for a signal; but why not schedule a task at 10:30PM that starts the program with ExitWindowsEx in it.<p>Automatically restarting at 6:30AM is going to harder.<p>On a couple of my PCs, holding the power button for like 15 seconds turns off the power. The power shuts off after about 5 seconds, but letting the button up too soon turns it on again.<p>Cheers,
Dale Y

Mike
Posts: 1813
Joined: Thu Mar 06, 2003 1:01 am
Location: Illinois
Contact:

Re: Power Switch for computer

Post by Mike » Sat Aug 14, 2004 4:37 am

I already got it to turn on automatically every day at 6:30 since its a feature of the BIOS, and off at 10:30 using shutdown.exe that I downloaded through the task scheduler. I now just want the power off switch. Right now, I hold it for 5 seconds, but I know thats an improper shutdown, so I try not to.

Bob Haller
Posts: 24
Joined: Tue Oct 01, 2002 1:01 am
Location: pittsburgh pa
Contact:

Re: Power Switch for computer

Post by Bob Haller » Sat Aug 14, 2004 5:59 pm

Hard drive manufacturers clain longer drive life, and longer everything life just leaving things run 24 7 in power save mode. The thermal cycling can be hard on your computer. I intentionally never turn mine off...They do go in sleep mode when inactive...

HodgeBrad
Posts: 8
Joined: Wed Dec 22, 2004 1:01 am
Location: Springdale, Arkansas
Contact:

Re: Power Switch for computer

Post by HodgeBrad » Fri Dec 31, 2004 8:22 pm

I agree about leaving it on all of the time. Much easier on the system. Should improve the life. However, you may not be that concerned with the life of that older computer; a failure could lead to an upgrade :)

User avatar
Chris Smith
Posts: 4325
Joined: Tue Dec 04, 2001 1:01 am
Location: Bieber Ca.

Re: Power Switch for computer

Post by Chris Smith » Fri Dec 31, 2004 9:47 pm

CTRL+ALT+DEL dosent work?

User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Power Switch for computer

Post by philba » Sat Jan 01, 2005 12:02 am

no, ctl-alt-del, holding the power button or simply switching off power (aka unplugging) doesn't work. The way I read it, he wants to cause the computer to go through a shut down/power down sequence with out touching the server's keyboard.<p>HP has it right. Just wire up a serial cable with a switch that connects RTS to CTS. Assert RTS and read CTS in a simple program (vb would be just fine). When CTS is high (i.e. the switch is set), execute the shutdown code. You might want to use a resistor to pull CTS low so it doesn't pick up noise can cause an inadvertent shutdown.<p>another approach is to create a web page with a button that runs a cgi script that runs a simple shut down program. Should be password protected, though. That way it could be shut down from anywhere, er, any computer.<p>Now, if he is using Win2K, and doesn't care about any open files, pulling the plug will be ok since the file system is pretty resilient. FAT file systems will have all sorts of problems. Still, not a good idea in general.<p>Phil

Mike
Posts: 1813
Joined: Thu Mar 06, 2003 1:01 am
Location: Illinois
Contact:

Re: Power Switch for computer

Post by Mike » Sat Jan 01, 2005 5:44 am

Thanks to everybody.<p>The only device I have hooked up is a mouse, because there is no room for a keyboard. So, what I did is make an icon on the desktop linking to that shutdown program I downloaded, so all I have to do is blindly move the mouse to the top right corner and double click, which isn't that hard.<p>It doesn't matter as much anymore, because I now host my website on that computer, so it needs to be on 24/7. Although I want to set it up to restart once every so often to keep it stable. I'm not sure if I should once a week, once every 2 weeks, once every month, or when? What do you think would be a good time period between restarts?

Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests