• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Shutting down Win2000 under program control

  In Windows 95/98, you can shut down or reboot Windows using the ExitWindowsEx User32 API call, ExitWindowsEx(2&, 0&) to reboot and ExitWindowsEx(1&, 0&) to shut down. This does not seem to work with Win2000. Does anyone know how to shut down and reboot Windows from within a program?
0
Leithauser
Asked:
Leithauser
1 Solution
 
jhanceCommented:
InitiateSystemShutdown() is the preferred method.  See:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/shutdown_04ry.asp

BTW, ExitWindowsEx will work on W2K also but you probably lack the privilege SE_SHUTDOWN_NAME in your process token.  You need it regardless of whether you use InitiateSystemShutdown() or ExitWindowsEx() and you usually get it via the AdjustTokenPrivileges() API call.
0
 
oricksCommented:
Use the shutdown.exe tool is in the Resource Kit.
to use:

shutdown \\pc_name /c /t:1

to have it rebooted:

shutdown \\pc_name /c /r /t:1
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LeithauserAuthor Commented:
None of these comments was able to answer my question, either because they were not sufficiently detailed or because the proposed solution involved external files. I found the solution I was looking for at this location
http://www.freevbcode.com/code/reboot.zip
This contained downloadable code that solved the problem. I therefore wish to withdraw or close down this question.
0
 
LeithauserAuthor Commented:
None of these comments was able to answer my question, either because they were not sufficiently detailed or because the proposed solution involved external files. I found the solution I was looking for at this location
http://www.freevbcode.com/code/reboot.zip
This contained downloadable code that solved the problem. I therefore wish to withdraw or close down this question.
0
 
LeithauserAuthor Commented:
None of these comments was able to answer my question, either because they were not sufficiently detailed
or because the proposed solution involved external files. I found the solution I was looking for at
this location
http://www.freevbcode.com/code/reboot.zip
This contained downloadable code that solved the problem. I am therefore deleting this question.
0
 
jhanceCommented:
Please explain.  The URL I posted is complete and the Microsoft recommended method.

I posted that comment 2 weeks ago and you've ignored it until now.
0
 
LeithauserAuthor Commented:
The pages you pointed to were simply not clear enough for me. They were a bit cryptic or did not define their terms clearly enough for me to use them. This may be partly my fault for not being familiar enough with their terminology, but the code I found and referred to in my answer was clear and could be cut and pasted directly into my program. It was therefore the correct answer, or at least the best answer. If you had pointed me to that code, I would have awarded you the answer.
0
 
jhanceCommented:
I just don't see how it could have been any clearer.  The URL I posted has a complete description of the system call as well as a link to another page with FULL SOURCE CODE of an example.

0
 
LeithauserAuthor Commented:
<<I just don't see how it could have been any clearer.>>

   It could have been clearer by being the answer I accepted. That is, somebody obviously hada clearer answer since I found one.
0
 
jhanceCommented:
There is no accepted answer here.  You were attempting to DELETE this question.

Take it up with the moderator...
0
 
LeithauserAuthor Commented:
 I did not say that the accepted answer was here, just that there was an answer that was clearer than yours and I found acceptable elsewhere. This answer was posted by someone in reply to someone who had asked essentially the same question as me right here on Expert Exchange. (When I got no satisfactory answer here, I did a much more thorough search than before of Expert Exchange.) This was in reply to your statement "I just don't see how it could have been any clearer." to show you that it could have been clearer.
   BTW, here is a link to a question that I just had answered and I accepted the answer, just to show that I do accept answers that do clearly answer my question.

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20291474
0
 
Computer101Commented:
Ok, here it is again.

Comment from me accepted as answer.  jhance, look for your question in this topic area.

Leithauser,
As stated in the previous question by you, the answer has been posted by jhance, but not to your satisfaction.  The same in this question.  The bottom line is, it is the correct answer.

Computer101
E-E Moderator
0
 
ComTechCommented:
Leithauser, please read below, these are the Grading guidelines you agreed to when signing up with EE.  Low grades are very uncommon, and weh you ask questions, the Experts will look at your grading profile, and if they see lower than A or atleast aberage, they wi probaly choose not to even participate next time.  If a comment leads you to a an answer, the Expert has done his/her job.
**********************************************************

How Do I Know What Grade to Give?
Although we use an A-D scale here at Experts Exchange, it works differently than, say, school grades. If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade, since they have taken the time to provide you with a working solution. If a possible solution is incomplete - ask for clarification or details before accepting the answer and grading it. People should not be given lower grades because of incorrect grammar or because you just accepted their answer or comment to close the question. Keep in mind, your question and any follow-up comments should be focused so that there can be a specific answer. The following is a good guideline to follow when grading:

A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.

B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.

C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.

Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support.

This is why the grades here.

Regards,
ComTech
CS @ EE
0
 
LeithauserAuthor Commented:
To ComTech:

   Thank you for the information on the grading system. However, I do not understand why it is posted here. I have not given a grade here.
   In the last week, I have accepted two answers on other questions. One I gave an unqualified A to. The other I did give a C to, and it fit the "not completely address the issue presented" description. It pointed me to a general subject that gave me an idea of where to look elsewhere for a partial answer, which told me what I had to do but not how to do it. Further inquiries lead to not result. I eventually found that out through my own research. I awarded the person the points for getting me started on the right path, but did not feel that I could honestly say the person had provided the answer.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now