Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What C++ commands are used to shutdown and restart PC?

Status
Not open for further replies.

ehsanelahimirza

Full Member level 6
Joined
Feb 24, 2006
Messages
334
Helped
28
Reputation
56
Reaction score
7
Trophy points
1,298
Activity points
3,570
shutdown restar in c++

hi all

plz tell me what commands r used to shutdown or restart a pc in c++

plz give me the syntax with some example
 

shutdown restar in c++

you can use the next:

Code:
 system ( "shutdown -s" )
for shutdown pc and
Code:
 system ( "shutdown -r")
for restarting a pc

also you can specify the time for shutdown pc:
Code:
 system ( "shutdown -s -t 3600" )
this code will shutdown pc after 1h

here is an example:
Code:
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    system("shutdown -s -t 3600");
    
    system("PAUSE");
    return EXIT_SUCCESS;
}
this will shutdown pc after 1h
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top