Solved

How to restart windows in VC++ without MFC?

Posted on 2001-08-15
10
491 Views
Last Modified: 2013-12-03
  I am making a console application so "ExitWindowsEx" will no work, is there any other way. I want to run it on Win98.
   Restarting of windows is required to update the Autoexec.bat file which I have updated by my program. Is there any other way of setting the changes made in autoexec.bat without restarting the windows.

Thanks in advance,
Nitin
0
Comment
Question by:nitinkale
  • 2
  • 2
  • 2
  • +1
10 Comments
 
LVL 5

Accepted Solution

by:
robpitt earned 60 total points
ID: 6391536
ExitWindowEx(EWX_REBOOT,0) should work.

Does this return true or false?
If false what is the return value from GetLastError()?

Also have you read the remarks section of the MSDN documentation for ExitEindowsEx, there it details what you need to do to make it work on NT. Note it also says:
"Windows 95/98/Me: ExitWindowEx does not work from a console application"

0
 
LVL 20

Expert Comment

by:Madshi
ID: 6391565
Please post your code - and the OS. In winNT/2k/XP you need enough privileges to successfully call ExitWindowsEx. What does GetLastError say after you called it?

Regards, Madshi.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6392117
>>>have tried the API "ExitWindowsEx" but it is not working in VC


Please define "not working".  The ExitWindowsEx API is KNOWN TO BE GOOD and it is used by 1000s of programs every day.  If you call it correctly, it will work.

Is this Windows 9x or NT/2000?  On NT/2000 your calling process MUST have the SE_SHUTDOWN_NAME privilege.  Your non-administrator account may not have this by default.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Expert Comment

by:jhance
ID: 6392118
By the way, if ExitWindowsEx() fails, it does return an error code.  Call GetLastError() and report the reason.
0
 
LVL 5

Expert Comment

by:robpitt
ID: 6393684
P.S.
Of course it might be failing because another app cancels the request (see WM_QUERYENDSESSION). To bypass this you would need to use the EWX_FORCE flag.
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6396927
all - according to the MS documentation ExitWindowsEx does not work from a console app on 95/98/Me and nitinkale has expressed a wish to do this from a console app on 98. If the documentaion is wrong please don't have a go at nitinkale but explaing why it is wrong
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6396960
nitinkale - you can turn you console app quite easily into a WIN32 app - use the wizards in visual studio and create a simple app - then copy your code from main() into WinMain() and away you go - then you can use ExitWindowsEx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now