Jump to content

Auto-Reboot Into SafeMode on WinXP


Recommended Posts

Hi, I am making my unattended Win XP Pro Setup and I have been trying to find a way to reboot into safe mode to finish installing certain files. I want this to happen automatically after setup finishes and then pick up where it left off. In safe mode it should automatically install a few files then reboot back into normal mode and be finished.

I have searched my a** off for a command line switch to reboot into safe mode on xp like u can for 95/98 but to no avail.

My recent failed attempt involved using the utility included in xp pro called BOOTCFG.exe.

It worked partly by rebooting and then entering safemode but I have no idea to pick up the script or another script after in safe mode.

Here is the beginning of the script..

@echo off
ECHO.
ECHO REBOOTING INTO SAFE MODE
ECHO.
bootcfg /raw /a /safeboot:minimal /id 1
SHUTDOWN -r -f -t 01

This script must be ran before rebooting or every boot will be in safe-mode:

bootcfg /raw /fastdetect /id 1
SHUTDOWN -r -f -t 01

ANY HELP WOULD BE GREATLY APPRECIATED.. I AM AT A DEAD END :(

Edited by TriPPiN
Link to comment
Share on other sites


I use a utility called change.com to change the default time out from 30 seconds to 10 seconds in boot.ini

With the same utility I can also add the following line ...

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Safe Mode" /fastdetect /safeboot:minimal /sos /bootlog

to get option of safe boot. If This is placed as the first choice it will automatically boot to safe mode.

Edited by pmshah
Link to comment
Share on other sites

I had a computer boot into safe mode unintentionally and it still ran my RunOnceEx scripts (which failed due to the unavailability of WMI). I wonder why it would work for some and not others?

Also, just in case it would be of use to anybody here, I've used a freeware utility for booting into safe mode that works pretty nice: BootSafe

Link to comment
Share on other sites

Thanks for the responses so far yet the resolution is still a mystery. :}

Pmshah: That utility serves no more purpose than "bootcfg.exe" included with WinXP Pro.

... The extra switches you used are unnecessary.

Roguespear: I happened to find "Bootsafe" before this post and it doesn't have a switch for silent use.

If the RunOnceEx key works during safe mode then I will have my solution by simply changing my script to the following:

RebootScript

@ECHO OFF
regedit /s c:\progs.reg
bootcfg /raw /a /safeboot:minimal /id 1
SHUTDOWN -r -f -t 01

Progs.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx]
"Reboot-Normal"="bootcfg /raw /fastdetect /id 1"
"Script2"="c:\\SafeModeScript.cmd"

SafeModeScript.cmd

@ECHO OFF
Start notepad.exe
Start wordpad.exe
SHUTDOWN -r -f -t 01

Edited by TriPPiN
Link to comment
Share on other sites

I've run a careful test for the following 10 run points.

The first two run points have been executed in safe mode.

The rest of run points have been executed after rebooting in normal mode.

The table maintains the order they have been executed.

:===========:=============:
:-CMD from--:--SAFE MODE--:
:===========:=============:
:-1-LM-ROEX-:-----YES-----:
:-----------:-------------:
:-2-CU-ROEX-:-----YES-----:
:-----------:-------------:
:-3-LM-RO---:-----NO------:
:-----------:-------------:
:-4-LM-POL--:-----NO------:
:-----------:-------------:
:-5-LM-RUN--:-----NO------:
:-----------:-------------:
:-6-CU-POL--:-----NO------:
:-----------:-------------:
:-7-CU-RUN--:-----NO------:
:-----------:-------------:
:-8-STRTP-A-:-----NO------:
:-----------:-------------:
:-9-STRTP-U-:-----NO------:
:-----------:-------------:
:10-CU-RO---:-----NO------:
:-----------:-------------:

Abbreviations:

LM-ROEX=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

CU-ROEX=HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnceEX

LM-RO=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

LM-POL=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\Run

LM-RUN=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

CU-POL=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\Run

CU-RUN=HKCU\Software\Microsoft\Windows\CurrentVersion\Run

STRTP-A="%AllUsersProfile%\Start Menu\Programs\Startup"

STRTP-U="%UserProfile%\Start Menu\Programs\Startup"

CU-RO=HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce

Link to comment
Share on other sites

Just tested the RunOneEx theory and it didn't work. Nothing that I put in either hklm or hkcu runoneex started up. The script that I wrote earlier would work perfectly if I could find a way to start a program at boot for safemode.

Also one more note.. when it reboots, a box comes up verifying if you want to enter safemode or not.. a method to bypass this box needs to be found for "silent" installation.

Link to comment
Share on other sites

I think you haven't used ROEX the correct way.

Please make another attempt using the following outlines.

@ECHO OFF

ECHO Rebooting into Safe Mode

SET LMROEX=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %LMROEX% /V TITLE /D "LM-ROEX SafeMoe" /f

REG ADD %LMROEX%\101 /vE /d "SafeMoe Installs" /f

REG ADD %LMROEX%\101 /v 1 /d %SystemDrive%\SafeModeScript.cmd /f

bootcfg /raw /a /safeboot:minimal /id 1

SHUTDOWN -r -f -t 01

Don't use your Progs.reg!

@ECHO OFF

ECHO Safe Mode Installs

Start notepad.exe

Start wordpad.exe

ECHO Rebooting into Normal Mode

bootcfg /raw /fastdetect /id 1

SHUTDOWN -r -f -t 01

Edited by mazin
Link to comment
Share on other sites

Success!!! This issue is now resolved!

With the help of (mazin) I have solved this mystery and programs can be run in safe mode automatically during windows setup. I reduced the code to one batch file that works perfectly on Windows XP. This batch must be run as the LAST install on windows setup!

@ECHO OFF

:: CHANGE PROG* TO INSTALLER/S BEING USED

SET PROG1=notepad.exe
SET PROG2=calc.exe

:: DON'T CHANGE THIS STUFF!

SET LMROEX=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
SET A=bootcfg /raw /fastdetect /id 1
SET B=bootcfg /raw /safeboot:minimal /id 1
SET C=SHUTDOWN -r -f -t 01

REG ADD %LMROEX%\Installers /ve /d "SafeMode Installs" /f
REG ADD %LMROEX%\Installers /v 1 /d "cmd /c start /w /min cmd /c %PROG1%" /f
REG ADD %LMROEX%\Installers /v 2 /d "cmd /c start /w /min cmd /c %PROG2%" /f

REG ADD %LMROEX%\Normal /ve /d "Exiting Safe Mode" /f
REG ADD %LMROEX%\Normal /v 1 /d "%A%" /f
REG ADD %LMROEX%\Normal /v 2 /d "%c%" /f
%B%
%c%
exit

Thanks for the help MAZIN.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...