-2

How do I create a shortcut that instantly shuts down the computer in the same way the computer instantly shuts down when holding my power button for 4 seconds. This is for PC.

I tried creating a shortcut using shutdown /s /t 0 but it does not shut down instantly. thanks.

4
  • Are you going to tell us whether it's Mac or a PC at all? Sep 14, 2014 at 18:03
  • Do you want to write a programm to do that? If so, in which language? Do you have a code example of what you've already tried?
    – lxg
    Sep 14, 2014 at 18:05
  • If a program can do that, yes. Any language is fine.
    – User345
    Sep 14, 2014 at 18:06
  • this may help stackoverflow.com/questions/15636059/… Sep 14, 2014 at 18:13

2 Answers 2

0

You can't do that. That's a hardware feature (cuts power to the machine, doesn't really 'shut down').

0

While its not quite possible to achieve what you described as it is a hardware feature, I believe you can mimic the behavior by sending Emergency Shutdown request to system. The result would be immediate session shutdown which is comparable in time with holding the power button.

In Windows you can achieve this by using NtShutdownSystem and NtSetSystemPowerState. There is a very nice article about this topic:

http://www.codeproject.com/Articles/34194/Performing-emergency-shutdowns

in Unix/Posix based system you should be able to do this by using:

echo 1 > /proc/sys/kernel/sysrq-trigger ;
echo o > /proc/sysrq-trigger

however you may need to obtain required privileges.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.