On most newer computers you can shutdown the hard way by pressing the power button for a couple of seconds. But I want to prevent this completely.
You're able to prevent some soft events like the sleep, suspend, hibernate and "Press power button" events in Windows control panel; you can also use some Win32 and WDI programming to catch and handle/deny those events but it doesn't seem to stop the mechanical power off when you hold the button for a longer time.
I guess the power button is hard-wired to the power supply and never waits for the OS when you hold it down for some seconds? Or is there some way to prevent even this case by code?
I'm a .NET developer.
Whooaaa...! Lots of you really argued for not doing this - "You don't own my computer or my OS", - "are you developing SkyNet" etc :) This application is a highly customized and closed solution for some customers. It's a kiosk application on customized hardware running on Windows XP Embedded and use a touch screen. It's not public.
Okay, so maybe it is insane to disable the power button. But we have a software application the uses a database and uses an expensive set of licenses. This large German vendor uses a license manager that moves the licenses physically around the drive. Defragging, certain anti-virus applications, and cutting the power corrupts the licenses. We have a UPS to allow elegant shutdowns if the machine power is cut. Now it seems some service guy or operator has powered down the PC with the power button corrupting the licenses. These devices are located in remote location all over the world and training the operator may not always prevent this. It seems like the solution options are 1) Work with the vendor to disable the power button, 2) attempt to trap it and warn the user of possible doom, or 3) redesign the display using an OS and application immune from this power removal.
See page 62 of the ACPI spec in relation to the 4-second rule (http://www.acpi.info/DOWNLOADS/ACPIspec30b.pdf)
Long and the short of it is that the logic is in hardware.
Unplug the power cable from the motherboard, and hardwire it to be on all the time. :)
It does make sense when the computer users are children and the power button becomes rather a game than an emergency action.The better way for a child to learn shutting down the machine via software is to disable mechanichal shutdown.
This is not possible as this Power off occurs below the operating system level so it is like pulling the plug as far as the OS is concerned!
I would suggest to somehow just taking the power button out of reach from the user. Maybe removing it completely. And making sure the computer turns on automatically when it gets power or something (not sure but could be possible in bios?).
Anyways, for an always on kiosk thing, this does kind of make sense. At least it does for much other hardware. Where the only way to turning it off is to cut the power.