PDA

View Full Version : Windows 98 boot into safe mode



Marty2001
18-10-2002, 12:57 PM
Hi F1

Does anyone know of a way to schedule a task on a W95/98 PC so that it will reboot, restart in safe mode and run a defrag (or at least how to make it restart in safe mode via a scheduled task from normal mode)?

Babe Ruth
18-10-2002, 03:54 PM
Marty,

Marty,
the safemode part is relatively simple... and you can do it in whatever way suits. You need to edit the AUTOEXEC.BAT file which is usually located in the root directory of your boot partition (often C: \ )

Add the line WIN /D:M - {this enables SafeMode startup} - to the AutoExec.bat file. Save it and reboot your PC.

To enable a quick reboot function you need to create a shortcut with the command rundll32.exe shell32.dll,SHExitWindowsEx 2

Still with me? What I'm doing is effectively building up a process which will - from 1 command (icon shortcut) - change the AUTOEXEC.BAT file reboot the pc and then... now this is where it keeps a little more tricky so I'll write something up and test it later this evening and post it back here for you.

Cheers, Babe.

Marty2001
18-10-2002, 08:45 PM
Thanks Babe

thats just what I needed

Babe Ruth
19-10-2002, 10:37 AM
Marty, Heres some stuff for you (and anyone else who wants)

Windows 98 Shutdown to SAFE Mode

Here is the first cut of some bits of code to do what you wanted... I will do the rest tomorrow for you.
Cut and paste the code files as below noting names and directory ( I have used C: ). Also you will need to create two shortcuts on your desktop to point to two of these files... (1) SafeMode_Restart and (2) Reset_From_SafeMode The First one is used to initiate the safemode restart and the second is used afterwards to reset the autoexec file back and reboot to full Windows mode.

Any questions please post back.

Cheers, Babe.


(1)
SM_SHUT.BAT - this file is run from a full Windows session to enable SAFE mode restart it should reside as SM_SHUT.BAT in C:\

@Echo Off
::
:: SM_SHUT.BAT setup to restart the PC in SAFE mode
::
:: Remove the attributes from the AUTOEXEC.BAT and CONFIG.SYS files
::
attrib -s -h -r c:\autoexec.bat >NUL
attrib -s -h -r c:\config.sys >NUL
::
:: Rename our old CONFIG file to CONFIG.SAV for safe keeping
::
if exist c:\config.sys rename c:\config.sys config.sav
::
:: Copy our old AUTOEXEC file to AUTOEXEC.SAV for safe keeping
::
if exist c:\autoexec.bat copy c:\autoexec.bat c:\autoexec.sav /Y >NUL
::
:: Copy our version of AUTOEXEC
::
copy c:\autoex_1.TXT c:\autoexec.bat /Y >NUL
::
:: Now restart the PC in SAFE Mode
::
rundll32.exe shell32.dll,SHExitWindowsEx 2
::
:: Could also use the following but the above works fine
:: rundll.exe user.exe,restartwindows
::

(2)
AUTOEX_2.BAT - this file resets the AUTOEXEC files back to what they were and restarts Windows it should reside as AUTOEX_2.BAT in C:\

@Echo Off
::
:: AUTOEX_2.BAT - this file resets the AUTOEXEC files back to what they were
::
:: This procedure should be run in SAFE mode to reset the AUTOEXEC batch file for the PC
::
:: Copy our old AUTOEXEC file back
::
if exist c:\autoexec.sav copy c:\autoexec.sav c:\*.bat /Y >NUL
::
:: Copy our old CONFIG.SYS file back
::
if exist c:\config.sav rename c:\config.sav config.sys
::
:: Now restart the PC
::
rundll32.exe shell32.dll,SHExitWindowsEx 2
::
:: Could also use the following but the above works fine
:: rundll.exe user.exe,restartwindows
::

(3)
AUTOEX_1.TXT - this file is the replacement AUTOEXEC.BAT file and starts Windows in SAFE mode it should reside as AUTOEX_1.TXT in C:\

@Echo Off
::
:: AUTOEX_1.TXT - this file is the replacement for AUTOEXEC.BAT
::
:: Run Windows 9.x in SAFE Mode
::
WIN /D:M
::