How to restart windows in VC++ without MFC?

  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,
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
>>>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.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

By the way, if ExitWindowsEx() fails, it does return an error code.  Call GetLastError() and report the reason.
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.
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
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.