Pregunta

I need to run a process one time after a reboot in safe mode, the process is this:

bcdedit.exe /import "%WINDIR%\Restore BootLoader Settings.bcd"

I've tried to use the RunOnce key but I've noticed that keys will not run under a Safe Mode boot so... exists any other way to run the damn process in a safe mode boot?

To be more explicit this is what I'm trying to do:

  1. In normal mode or whatever else mode I export the current settings of all the Boot Loader entries.

  2. Then I change some parametters of the current boot loader entry and then I reset the PC.

  3. Here is the problem, when logged again in Windows in safe mode for example I need to restore (import) the settings before my new changes to don't still booting ever in safe mode when resetting the machine.

How can I do that?

This is my vbs script:

' Restart in Safe Mode
' By Elektro H@cker

If Not Msgbox( _
    "¿Seguro que quieres reiniciar el equipo?", _
    4 or 48, _
    "Reiniciar en Modo Seguro..." _
    ) = vbNo _
Then

Set wshShell = WScript.CreateObject("WScript.Shell")

TempFile = """" & wshShell.ExpandEnvironmentStrings("%WINDIR%") & "\" & "Bcdedit settings.bcd" & """"

wshShell.Run "bcdedit /export " & TempFile, 0, True
wshShell.Run "bcdedit /set {current} safeboot minimal", 0, True

wshShell.RegWrite _
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\Restore BootLoader Settings",  _
"bcdedit.exe /import " & TempFile, _
"REG_SZ"

wshShell.Run "shutdown -r -t 00 -f", 0, True

End If

¿Fue útil?

Solución

I just learnt something new here:

As per: http://msdn.microsoft.com/en-us/library/aa376977%28v=vs.85%29.aspx

By default, these keys are ignored when the computer is started in Safe Mode. The value name of RunOnce keys can be prefixed with an asterisk (*) to force the program to run even in Safe mode.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top