Q

Using C, what is the interrupt I can use to make a computer shut down and restart?

I would like to know the interrupt with which a computer can be made to shut down and restart. I am using C language to develop the application.
You didn't mention which operating system you're using. Since this column is from SearchWin2000.com and is about programming for Windows, I'll assume that you're running one of the Microsoft operating systems.

First off you can't trip an interrupt except from a device driver. Fortunately, Microsoft provides several functions that will shut down and restart the computer for you. For Windows 9x/Me, you can use ExitWindowsEx and pass EWX_REBOOT as the ulFlags parameter. For Windows 2000 and above, the user account calling the code will need to have the SE_SHUTDOWN_NAME privilege, so you'll need to call AdjustTokenPrivileges to get the privilege. If you successfully acquire the privilege, you can call InitiateSystemShutdownEx, which gives you more control over how the shutdown and restart will perform than ExitWindowsEx.

This was first published in September 2002

Dig deeper on Microsoft Windows 2000 Server Administration

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close