Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Rebooting to safe mode...

Rebooting to safe mode...

Scheduled Pinned Locked Moved C#
csharpquestionhtml
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jacob D Dixon
    wrote on last edited by
    #1

    How could one reboot a local computer to safe mode using C#? I have used google to search for this and not finding much. I did find a question posted for the exact same thing here on codeproject from '06 but the reply the guy got was this was not possible. I see this for shutting down or rebooting: http://pinvoke.net/default.aspx/wtsapi32/WTSShutdownSystem.html[^] Before you say this cannot be done, I currently use a Windows application that can reboot a computer to safe mode. Not sure how they do it, but they are somehow.

    H 1 Reply Last reply
    0
    • J Jacob D Dixon

      How could one reboot a local computer to safe mode using C#? I have used google to search for this and not finding much. I did find a question posted for the exact same thing here on codeproject from '06 but the reply the guy got was this was not possible. I see this for shutting down or rebooting: http://pinvoke.net/default.aspx/wtsapi32/WTSShutdownSystem.html[^] Before you say this cannot be done, I currently use a Windows application that can reboot a computer to safe mode. Not sure how they do it, but they are somehow.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      I have never tried this but your question intrigued me so I did a little googling. If the OS on the computer is XP or before how about temporarily editing Boot.ini to add a /SAFEBOOT switch (source[^]), with a runonce registry entry to reset afterwards. I'm not sure how Vista and Weven work but a similar technique might be possible.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      J 1 Reply Last reply
      0
      • H Henry Minute

        I have never tried this but your question intrigued me so I did a little googling. If the OS on the computer is XP or before how about temporarily editing Boot.ini to add a /SAFEBOOT switch (source[^]), with a runonce registry entry to reset afterwards. I'm not sure how Vista and Weven work but a similar technique might be possible.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        J Offline
        J Offline
        Jacob D Dixon
        wrote on last edited by
        #3

        Well you came up with more than I did. I was hoping to get around manually editing the boot ini file with my code. Even if I did that would it go off once it booted into safe mode or will it continue to boot into safe mode every time it reboots? Note: I guess I could try opening reflector and finding this code and how they are doing it. Do you know if this is legal for me to do?

        H 1 Reply Last reply
        0
        • J Jacob D Dixon

          Well you came up with more than I did. I was hoping to get around manually editing the boot ini file with my code. Even if I did that would it go off once it booted into safe mode or will it continue to boot into safe mode every time it reboots? Note: I guess I could try opening reflector and finding this code and how they are doing it. Do you know if this is legal for me to do?

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          Jacob D Dixon wrote:

          Note: I guess I could try opening reflector and finding this code and how they are doing it. Do you know if this is legal for me to do?

          Probably not, if you use the code directly. Although if it's not obfuscated there is no harm in just having a look, to satisfy your curiosity. I used to do a similar thing back in the DOS days with the Autoexec.bat and Config.sys for some programs (Games mostly) that required non standard settings. In your situation, make a copy of Boot.ini, rename it Boot.ini.safe (safe mode), or similar. Make another copy and rename it Boot.ini.std (standard mode). Modify the .safe file to include the /SAFEBOOT stuff. BTW: Try the next bit out manually first, to make sure that it works. I used to do the next bit using batch files, you could do the same, or write a small app to do it. 1. Delete Boot.ini 2. Depending on whether you're going from standard to safe, or the other way, copy the Boot.ini.safe/Boot.ini.std file as Boot.ini. 4. When going to Safe mode add the entry to Runonce in the registry to run the app/batch that prepares for standard boot on next restart. 3. Restart. [Edit] Just discovered that step 4, above won't work See Notes section in this[^]. Hmmm and it seemed like such a good idea. :( [/Edit]

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          J 1 Reply Last reply
          0
          • H Henry Minute

            Jacob D Dixon wrote:

            Note: I guess I could try opening reflector and finding this code and how they are doing it. Do you know if this is legal for me to do?

            Probably not, if you use the code directly. Although if it's not obfuscated there is no harm in just having a look, to satisfy your curiosity. I used to do a similar thing back in the DOS days with the Autoexec.bat and Config.sys for some programs (Games mostly) that required non standard settings. In your situation, make a copy of Boot.ini, rename it Boot.ini.safe (safe mode), or similar. Make another copy and rename it Boot.ini.std (standard mode). Modify the .safe file to include the /SAFEBOOT stuff. BTW: Try the next bit out manually first, to make sure that it works. I used to do the next bit using batch files, you could do the same, or write a small app to do it. 1. Delete Boot.ini 2. Depending on whether you're going from standard to safe, or the other way, copy the Boot.ini.safe/Boot.ini.std file as Boot.ini. 4. When going to Safe mode add the entry to Runonce in the registry to run the app/batch that prepares for standard boot on next restart. 3. Restart. [Edit] Just discovered that step 4, above won't work See Notes section in this[^]. Hmmm and it seemed like such a good idea. :( [/Edit]

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            J Offline
            J Offline
            Jacob D Dixon
            wrote on last edited by
            #5

            LOL. Let me give some things a try. Your suggestions got me further than I was. There are some things that I want to know how this application does stuff. It also provides like a VNC redirecting type function where the control center application is on your computer, then you have the server, then you have agents (which could be on a different network behind a different firewall). So the agent started the VNC with the server, then somehow the server redirects all that traffic to the control center. It is all a learning curb for me. So my way of learning is trying to duplicate the server / client application they made (slimmed down version of course). Let me try some things and also snoop around in their code and I'll let you know what info I come up with. thanks for the information you already provided!

            R 1 Reply Last reply
            0
            • J Jacob D Dixon

              LOL. Let me give some things a try. Your suggestions got me further than I was. There are some things that I want to know how this application does stuff. It also provides like a VNC redirecting type function where the control center application is on your computer, then you have the server, then you have agents (which could be on a different network behind a different firewall). So the agent started the VNC with the server, then somehow the server redirects all that traffic to the control center. It is all a learning curb for me. So my way of learning is trying to duplicate the server / client application they made (slimmed down version of course). Let me try some things and also snoop around in their code and I'll let you know what info I come up with. thanks for the information you already provided!

              R Offline
              R Offline
              Rose WiFiTech Electronics Library Research Cen
              wrote on last edited by
              #6

              thanks to both of you.. now I know how to do routine at least it works.. I usually restart to Safe/DOS mode to remove manually the Autorun.inf of any USB Drive suspected with virus. this at least I can prevent it from transferring to my hard drive. I just copy only the Docs and Xls files.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups