Mega Code Archive

 
Categories / Delphi / System
 

Stop windows from going into safemode

Title: Stop windows from going into safemode Question: Is there any way to prevent windows from getting into safemode ? Answer: All the information below refers to win95/98/me. I tested it only on WinME. The main ideea is to stop windows from getting into safemode and letting the nosy user from altering precious data from here (well he could just get it done in MS-DOS but it'll be harder for him, or maybe quite impossible (the registry - I mean not that he could not delete it). It can be helpfull for the people using programs (FolderGuard) that work best or only when windows had a normal startup. The simple thing to do would be to reset the computer if it tries load windows not normal. A small executable is used for this job. here is the source: program nosafemode; const SM_CLEANBOOT = 67; EWX_REBOOT = 2; function GetSystemMetrics(nIndex : integer) : integer; stdcall; external 'user32.dll'; function ExitWindowsEx(uFlags : Word; dwReserved : LongWord) : boolean; stdcall; external 'user32.dll'; begin if GetSystemMetrics(SM_CLEANBOOT)0 then ExitWindowsEx(EWX_REBOOT,0); end. GetSystemMetrics returns 1 or 2 if windows didn't have a normal boot. ExitWindowsEx exits windows. With EWX_REBOOT as the first param it resets the computer. In SafeMode windows bypasses the registry (and with it all the 'run' entries that might help a program load on startup) and autoexec.bat, config.sys. The programs listed on the 'load=' and 'run=' lines in the [windows] section of the win.ini file are not loaded. Although the [boot] section is said to be bypassed the 'shell=' and 'drivers=' lines are processed. So here is the only way an executable can load on a safemode startup. an entry like the one below in system.ini should do it : [boot] ... shell=Explorer.exe (i.e: shell=Explorer.exe c:\nosafemode.exe) ... So, whenever windows boots to safemode the computer is reset pretty fast. There may be extremely fast users that might stop the process, but hey! it's a way to do this. I'm waiting for any suggestions that anybody might have on this. Oh there is one other thing. Maybe this works on your OS too. On my version of WinME did. I edited msdos.sys (change the attribs so that it's writable) and added/modified: [Options] BootMulti=0 BootGUI=0 BootDelay=0 BootMenuDelay=0 BootSafe=0 BootKeys=0 BootMenu=0 I didn't test which part did it, but I tried all the techniques to get to safemode (F5, F8 to get the boot menu, pressing Shift key while booting, reseting computer while booting so that windows would say faulty last load) and I couldn't ! Just change everything it doesn't err :) . If this doesn't work try my first ideea. Of course the start-up floppy still does it's job.