Solved

How to restart windows in VC++ without MFC?

Posted on 2001-08-15
10
501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 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