Solved

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

Posted on 2002-04-04
3
204 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 31

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand to include initial dialog with two choices. 9 76
Tab names are off by one 5 54
method notes when mouse over in eclipse 5 86
has77  challenge 9 82
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

11 Experts available now in Live!

Get 1:1 Help Now