| | |
How to shutdown your computer using C++?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I know the dos command is "shutdown" then with your parameters of "-s -t xxx" etc.
Anyways so "How to shutdown your computer using C++?"
Thanks, Regards X
Anyways so "How to shutdown your computer using C++?"
Thanks, Regards X
"You never stop learning." - OmniX
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Im a newb to C++, what paramters need to be used with the functions and do they require an include file? possible small example?
Thanks, Regards X
Thanks, Regards X
"You never stop learning." - OmniX
•
•
Join Date: Feb 2009
Posts: 141
Reputation:
Solved Threads: 2
Something like this
Shuts it down in ten seconds this is using dev c++
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main () { system("shut down -s -t 10"); return 0; }
Shuts it down in ten seconds this is using dev c++
It is "shutdown" no space but even then didnt work, are you 100% sure it worked with yours?
"You never stop learning." - OmniX
Firstly, don't use sysrtem. use the function given to you by AncientDragon.
Secondly for an example, read the page it has a link to one.
Thirdly, that page tells you what parameters are needed, what they could be and what they do. Also it tells you what headers you need etc.
Please read information when someone points you to it, they don't do it for fun. They do it to try and help.
Chris
Secondly for an example, read the page it has a link to one.
Thirdly, that page tells you what parameters are needed, what they could be and what they do. Also it tells you what headers you need etc.
Please read information when someone points you to it, they don't do it for fun. They do it to try and help.
Chris
Last edited by Freaky_Chris; Mar 20th, 2009 at 5:50 am.
Knowledge is power -- But experience is everything
Ok thankyou Chris for that abusive and useless post. (If I didnt need help I wouldnt have posted)
If someone can give me an example using ExitWindowsEx(), like power_computer tried to give me one using system("").
My attemps have included:
So any ideas?
Thanks, Regards X
Thanks
If someone can give me an example using ExitWindowsEx(), like power_computer tried to give me one using system("").
My attemps have included:
cpp Syntax (Toggle Plain Text)
ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_OTHER); // AND system("shutdown -s -t 180");
So any ideas?
Thanks, Regards X
Thanks
Last edited by OmniX; Mar 20th, 2009 at 9:11 am.
"You never stop learning." - OmniX
Delete line 3 (system(...) because its not needed. Otherwise, your line #1 looks ok to me, as long as you are running as administrator account.
Last edited by Ancient Dragon; Mar 20th, 2009 at 9:31 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Ya they were just my attemps nothing works, this is my whole code below.
I am assuming that my ExitWindowsEx line is fine? (Whoops my internet is lagging didnt see ur second line)
Am I missing include files? Variables? Etc? I have vista also.
So what looks to be the problem?
Thanks, Regards X
I am assuming that my ExitWindowsEx line is fine? (Whoops my internet is lagging didnt see ur second line)
Am I missing include files? Variables? Etc? I have vista also.
So what looks to be the problem?
cpp Syntax (Toggle Plain Text)
// Include Files #include <iomanip> #include <iostream> #include <stdio.h> #include <time.h> #include <windows.h> using namespace std; int main () { // Shutdown cout << "Shutdown Complete!" << endl; ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_OTHER); //system("shutdown.exe -s -t 180"); // Return Carriage return 0; }
Thanks, Regards X
Last edited by OmniX; Mar 20th, 2009 at 9:45 am.
"You never stop learning." - OmniX
![]() |
Similar Threads
- Remote Computer Shutdown (Windows NT / 2000 / XP)
- AUTO SHUTDOWN Windows XP Pro? (Windows NT / 2000 / XP)
- shutdown.exe (Question) (C#)
- Creating Desktop Shutdown Icon (Windows NT / 2000 / XP)
- Installing a new card (PCI), computer does not do anything when card is in (Monitors, Displays and Video Cards)
- Shutdown Trouble in Windows 98 (Windows 95 / 98 / Me)
- Forgot Password Cant Get Into Computer (Windows NT / 2000 / XP)
- Computer freezes on logoff (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Improvements to Quicksort using the Median of 3 partition and Insertion sort
- Next Thread: no matching function call to for_each
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






