954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to reboot computer via C?

Please can anyone help me out of this problem?
I want to know that how can we reboot computer (any OS) using C language?

jainam2209
Newbie Poster
1 post since Sep 2007
Reputation Points: 10
Solved Threads: 0
 

That would depend upon OS. For example in windows the WinAPI function is ExitWindowsEx . In other systems its other. In DOS its quite simple as windows one and here an article on that. I dont know about any other.

vishesh
Nearly a Posting Virtuoso
1,381 posts since Oct 2006
Reputation Points: 85
Solved Threads: 42
 

You may use the system function!

StrikerX11
Light Poster
27 posts since Jun 2007
Reputation Points: 10
Solved Threads: 7
 
You may use the system function!


That might work with *nix, but not MS-Windows.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
#include <dos.h>
system ("shutdown +a"); // to enable automatic shutdown
system ("shutdown -s -t 1"); //to shutdown in 1 second
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

I just find it suspicious whenever someone shows up and their first post is "how do I reboot". This just screams "kiddie pest" to me.

Just so you know, there is no "any OS" answer to this.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

Generalization means Windows as he didn't mention a specific OS.

Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You