Page 1 of 1
Smallest code ever to reboot on all PCs
Posted: Tue Nov 25, 2003 3:44 am
by PB
I know this is just a dirty hack, and I would never actually use it in a full
release app, but it seems to be the smallest code ever to reboot a PC on
all versions of Windows.
Edit: Modified to run on ANY language version of Windows now.
Works on Windows 95, 98, ME, 2000 and XP (tested fine on all).
Code: Select all
; WARNING: YOUR PC WILL REBOOT IF YOU RUN THIS CODE!
Procedure Reboot()
fg=GetForegroundWindow_()
Repeat : Sleep_(1) : Until GetForegroundWindow_()<>fg
keybd_event_(#VK_RETURN,0,0,0)
EndProcedure
CreateThread(@Reboot(),0)
SetupPromptReboot_(0,0,0)
Posted: Tue Nov 25, 2003 10:09 am
by dmoc
You mean apart from...
Code: Select all
MessageRequester("", "Press reset now")
repeat: forever

Posted: Tue Nov 25, 2003 12:32 pm
by Seldon
Sorry, but what's wrong with this code ? ->
ExitWindowsEx_(#EWX_FORCE|#EWX_REBOOT,0)
As I'm using it on Win98SE and it works.. maybe are there problems on NT/2000/XP ?
Posted: Tue Nov 25, 2003 12:47 pm
by tinman
Seldon wrote:Sorry, but what's wrong with this code ? ->
ExitWindowsEx_(#EWX_FORCE|#EWX_REBOOT,0)
As I'm using it on Win98SE and it works.. maybe are there problems on NT/2000/XP ?
Your program needs certain security permissions to reboot the system under NT based versions of Windows. I dunno if this is just a case of running it as a user with enough security, or perhaps your program can ask for it.
Posted: Tue Nov 25, 2003 1:00 pm
by Berikco
tinman wrote:Seldon wrote:Sorry, but what's wrong with this code ? ->
ExitWindowsEx_(#EWX_FORCE|#EWX_REBOOT,0)
As I'm using it on Win98SE and it works.. maybe are there problems on NT/2000/XP ?
Your program needs certain security permissions to reboot the system under NT based versions of Windows. I dunno if this is just a case of running it as a user with enough security, or perhaps your program can ask for it.
It will not work on NT/w2k/Xp/2003 , not even if you are loged on as administrator.
The complete code to use ExitWindowsEx_() on NT/.... has been posted a couple of times.
Posted: Wed Nov 26, 2003 4:38 am
by PB
> ExitWindowsEx_(#EWX_FORCE|#EWX_REBOOT,0)
> I'm using it on Win98SE and it works.. maybe are there problems on
> NT/2000/XP ?
Correct, it won't work on NT/2K/XP. My tip does, though. However, my
tip is not something you'd actually use, as it depends on the language of
the OS installed and so on -- and is just a hack method anyway. I found
the SetupPromptReboot API from the API-Guide app (sorry, no URL) and
decided to see if I could force a reboot with it, and I could -- so I posted
it here as an example.

Posted: Wed Nov 26, 2003 9:43 am
by Berikco
Yes, small code, but ist going to get bloated if you must include for all languages

Posted: Wed Nov 26, 2003 9:51 am
by PB
> Yes, small code, but ist going to get bloated if you must include for all languages
LOL, that's very true!
