Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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