I have scoured the web looking for solutions on how to SafeBoot into Windows using only C#. Since Vista and above, safe booting is controlled using BCD. Ofcourse you could use the commandline tool "bcdedit":
bcdedit /set {current} safeboot Minimal
However I do not want to use this approach. So my question is:
How do I reboot into safe mode using only C#?
I have already looked at this SO post, which has got me started. But I'm still missing pieces to this puzzle.
Any help is greatly appreciated. =)
BCD WMI Provider Reference is of little help.
I wrote up the following code in C# that should allow you to set the safeboot value and delete that value:
I tested this on my Surface Pro and it seemed to work, as can be verified by running:
Update:
The code above is just for setting or removing the value that allows you to safeboot.
After this has been performed, a reboot is required, which can also be accomplished using WMI as is shown here:
WMI to reboot remote machine
The answer shows an example for performing this locally or remotely.
Big thanks to Helen and L-Williams.