Page 1 of 1

Power Switch for computer

Posted: Thu Aug 12, 2004 7:09 pm
by Mike
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!

Re: Power Switch for computer

Posted: Thu Aug 12, 2004 7:55 pm
by hp
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

Re: Power Switch for computer

Posted: Fri Aug 13, 2004 11:53 am
by haklesup
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

Re: Power Switch for computer

Posted: Fri Aug 13, 2004 7:31 pm
by Mike
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?

Re: Power Switch for computer

Posted: Fri Aug 13, 2004 9:32 pm
by dyarker
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,

Re: Power Switch for computer

Posted: Sat Aug 14, 2004 4:37 am
by Mike
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.

Re: Power Switch for computer

Posted: Sat Aug 14, 2004 5:59 pm
by Bob Haller
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...

Re: Power Switch for computer

Posted: Fri Dec 31, 2004 8:22 pm
by HodgeBrad
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 :)

Re: Power Switch for computer

Posted: Fri Dec 31, 2004 9:47 pm
by Chris Smith
CTRL+ALT+DEL dosent work?

Re: Power Switch for computer

Posted: Sat Jan 01, 2005 12:02 am
by philba
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

Re: Power Switch for computer

Posted: Sat Jan 01, 2005 5:44 am
by Mike
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?