CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2003
    Posts
    322

    Programmatically restarting Windows in Safe Mode to update firmware

    I know there are API's to reboot the system,
    InitiateSystemShutdown() is just one of them.

    However, I need to update firmware in an embedded device, and there's no way I want to attempt this with Windows running.

    I'm thinking I need to reboot in Safe Mode or force a reboot to the F8 screen.

    This URL makes mention of using environment variables during a reboot
    [URL=http://support.microsoft.com/kb/315222]

    Safe Mode with Command Prompt (SAFEBOOT_OPTION=Minimal(AlternateShell)): This option is the same as Safe mode, except that Cmd.exe starts instead of Windows Explorer.

    or
    An environment variable is set when you use one of the Safe Boot options. The environment variable is SAFEBOOT_OPTION. This variable is set to either Network or to Minimal.


    I've tried manually going into Control Panel, creating those environment variables, then use Ctrl-Alt-Delete to reboot. Oddly enough, the system reboots, and those vars are no longer in control panel. T
    The system did not go into Safe Mode as I had expected. I've been pouring over the MSDN, but I'm obviously using the wrong terminology for searching.

    1. Would someone point me to some code/docs which shows how to "programmatically" reboot a machine in Safe Mode (or console only)?

    2. Is there a way to programmatically reboot an XP machine so it reboots into the "Windows Advanced Options Menu (The F8 screen)?

    3. Is it possible to programmatically create an entry in the
    "Windows Advanced Options Menu (The F8 screen), so the user can select
    "Download firmware to My Device"?

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    I went to MSCONFIG to the Boot.ini tab, and when I selected /safeboot and Apply, the env variable was added to the startup line right under Operating System. You can probably modify that file yourself.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Apr 2003
    Posts
    322

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    Quote Originally Posted by dglienna
    I went to MSCONFIG to the Boot.ini tab, and when I selected /safeboot and Apply, the env variable was added to the startup line right under Operating System. You can probably modify that file yourself.
    Thanks. I've tried this.
    Where is boot.ini? I did a search with explorer from the root of c, and could not find it.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    It's hidden. Go to your System Properties, and on the Advanced tab, click the startup options, and click EDIT. It appears to be in the root partition.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Apr 2003
    Posts
    322

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    Quote Originally Posted by dglienna
    It's hidden. Go to your System Properties, and on the Advanced tab, click the startup options, and click EDIT. It appears to be in the root partition.
    Ok- I can see it from control panel.
    I've got "Do not hide system and hidden files" specified in Explorer, but this file is still hidden.

    If I make edits to this through a program, will these edits be "retained" or will Windows overwrite this file before shutting the system down?

  6. #6
    Join Date
    Oct 2006
    Posts
    327

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    I suggest you have a good look to the next chexkbox which is concerning a certain mask to apply or not to apply to the protected files !

  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    I would guess that the info is in the registry, as well, but haven't looked at where it may be.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Apr 2003
    Posts
    322

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    Quote Originally Posted by dglienna
    I would guess that the info is in the registry, as well, but haven't looked at where it may be.
    That assumes one knows where to look and what to look for.

  9. #9
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Programmatically restarting Windows in Safe Mode to update firmware

    Well, I found a MSCONFIG Hive that seems to have the keys that get set. Only one of four is set on my machine. I'd look to see which ones change when you change settings in msconfig.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured