Solved

How could I reset my machine using C++ code?

Posted on 2002-04-04
3
186 Views
Last Modified: 2013-11-20
I need to reset a machine (local or remote) from my application (MFC exe). How could I do it?

Thanks.
0
Comment
Question by:svillalba
3 Comments
 
LVL 30

Expert Comment

by:Zoppo
ID: 6918419
Hi svillalba,

you can either use ExitWindowsEx() or InitiateSystemShutdown() which is not available in Win9x/Me...

hope that helps,

ZOPPO
0
 
LVL 3

Expert Comment

by:Crius
ID: 6918425
Wait... Are you sure you want to reset it?
To reset a machine, you can use a simple assembly command, and just tell it to jump (jmp) to memory F0F0:F0F0, and that's a pretty effective reset, though you'll likely lose all your windows unsaved data since it's not a clean shutdown. I believe F0F0:F0F0 is equivalent to FFFF:0000 but I'm not certain.

Here is a list of non-reset alternatives I suggest:

DOS ECHO G=FFFF:0000 ¦ DEBUG  Reboot (warm boot, sometimes cold boot)(2)
Win31* ECHO G=FFFF:0000 ¦ DEBUG  Popup Task Manager, sometimes reboot
Win9* RUNDLL USER.EXE,ExitWindows  Shutdown (3)
Win9* RUNDLL USER.EXE,ExitWindowsExec  Win95: various results, usualy fast shutdown (and lock PC), sometimes restart Windows, sometimes reboot.
Win98: Restart Windows, sometimes reboot.
Win9* RUNDLL SHELL.DLL,RestartDialog  "System Settings Change, Do you want to restart your computer now?" dialog
Win98/ME RUNDLL32 SHELL32.DLL,SHExitWindowsEx n  Where n can be any combination (sum) of the following numbers: (4)
0    Logoff
1    Shutdown
2    Reboot
4    Force
8    Poweroff (if supported by the hardware)
 
Win98/ME RUNONCE.EXE -q  Reboot (4)
NT See Reboot NT on my Solutions found in alt.msdos.batch page Reboot immediately
NT RUNDLL32 USER32.DLL,ExitWindowsEx
RUNDLL32 USER32.DLL,ExitWindowsEx  Logoff (most systems require the command to be called twice before logging off)
NT+RK SHUTDOWN /L /R /T:0 /Y  Immediate shutdown & reboot
NT+RK SHUTDOWN /L /T:10 /Y /C  Shutdown in 10 seconds, close without saving (can be stopped during those 10 seconds using SHUTDOWN /A)
XP SHUTDOWN -r -t 10  Reboot after a 10 seconds delay (can be stopped during those 10 seconds using SHUTDOWN -a)
XP SHUTDOWN -s -t 01  Shutdown after a 1 second delay (but no poweroff)
Kix $RC = SHUTDOWN( "\\server", "Shutting down...", 10, 1, 0 )  Shutdown in 10 seconds, with message, close without saving, no reboot
Kix $RC = SHUTDOWN( "\\server", "", 0, 1, 1 )  Immediate shutdown & reboot, without a message
Kix $RC = LOGOFF( 1 )  Logoff, forcing applications to close (use 0 instead of 1 if you don't want to force applications to close)
WSH [1] Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
[2]
[3] for each OpSys in OpSysSet
[4]     OpSys.Reboot()
[5] next  Reboot
 
(Remove [line numbers].
Found in a forum posting by Alex Angelopoulos on www.developersdex.com)
OS/2 START /PM SHUTDOWN && EXIT  Shutdown (5)
OS/2 SETBOOT /IBD:C:  Unconditional shutdown & reboot
OS/2 SETBOOT /IBA:nonsense  Unconditional shutdown & failing reboot (6)
OS/2 LOGOFF  Logoff (both LAN Server client and Peer)
0
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 6918427
"Remote" works only for NT/W2k using "InitiateSystemShutdown()": http://www.mvps.org/win32/processes/rb.c

If you need to restart a Win9x/ME machine, 'ExitWindowsEx()' will work for you:

ExitWindowsEx(EWX_REBOOT, 0);
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

746 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