How to restart windows in safe mode using C++ ???

closed account (3hMz8vqX)
Hi all,
it has been so long since i visited this forum . . .

So, i need to know how to restart windows in safe mode. I know you can edit the boot.ini in xp but how would you go about in windows 7 and later

Please answer this I am familiar with WINAPI Thankyou everyone in advance !
If you want an easy way to boot into safe mode, write yourself a couple of command scripts. Something like this should do the trick:
1
2
3
@echo off
bcdedit /set safeboot network
shutdown -r -f -t 0
SafeBootOn.cmd

1
2
3
@echo off
bcdedit /deletevalue safeboot
shutdown -r -f -t 0
SafeBootOff.cmd

NB: Probably need to run them as administrator
Last edited on
There is the BCD WMI Provider:

Boot Configuration Data WMI Provider
http://msdn.microsoft.com/en-us/library/windows/desktop/bb986746%28v=vs.85%29.aspx

Andy

PS I've only ever used the WMI API to query for various bits of system configuration information; never to edit the BCD config. But this post does suggest that the WMI route could be "fun"...

Help on code to edit BCD data using WMI APIs
http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/92adc6ad-f44d-4e28-82c9-47bdff26e841/help-on-code-to-edit-bcd-data-using-wmi-apis
Last edited on
closed account (3hMz8vqX)
Thankyou all,
for your reply . . .
the batch file does the job!
but I would like to know how to use the ExitwindowsEx booting into safe mode ???
I am using codeblocks i dont know how to use WMI . . . :(

anyways Thankyou everyone in advance !
ExitwindowsEx does not allow you to define which o/s config starts up when you reboot. For that you need to use bcdedit or the BCD WMI Provider.

Andy


I misunderstood the question, I was thinking that @OP want to restart windows when the application is running in safe mode, sorry.
Last edited on
closed account (3hMz8vqX)
Thankyou all for your help !
I will use the batch file!
please answer all my questions that i will be posting in this forum!

-Aravind
Topic archived. No new replies allowed.