Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-04-04
3
Medium Priority
?
230 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
[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
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 200 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

722 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