Solved

How to restart windows in VC++ without MFC?

Posted on 2001-08-15
10
488 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 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

12 Experts available now in Live!

Get 1:1 Help Now