1. This forum is for tutorials and this post doesn’t belong here.
2. The example code you are asking about will never work, simply because once a system shuts down it is OFF and stops responding to the users code/ inputs… a scenario that has a computer shut down then hibernate isn’t workable.
3. In Windows 8.1 there is already built in timers for screensavers, sleep, shut down and hibernate and these can be set from the power options or you can set the system (also in power options) to hibernate strait away when a [hibernate key] is pressed… most laptops also allow you to hibernate when the lid is closed.
4. Some of the better name brands like Asus and Gateway allow you to set hibernate and wake up setting in the motherboard bios… these tend to be for scenarios that have a system waking up/ hibernating after receiving a ping across the network so that servers can be reached remotely but there is some flexibility built into their system.
Finally hibernating has several performance issues that Windows never managed to fully resolve and has been fazed out in favour of the sleep command… one of the main 3 advantages of using the current UEFI system is it’s fast wake up/ boot and that largely makes the hibernate system (outside of legacy installs) redundant.