Here is the c++ code with command, command for run windows in safeboot with network mode and restart, This code run only in 32 bit operating system but in 64 bit only restart will happen but not in safeboot mode.
[NOTE] : I run application in administrative mode.
system("bcdedit /set safeboot network > Out.txt");
system("shutdown -r -f -t 0");
and also with ShellExecute()
ShellExecute(0, L"open", L"cmd.exe", L"/C bcdedit /set safeboot network > Out.txt", 0, SW_HIDE);
ShellExecute(0, L"open", L"cmd.exe", L"/C shutdown -r -f -t 0 > Out.txt", 0, SW_HIDE);
I tried manually like Open CMD in administrative mode
c:\WINDOWS\system32>bcdedit /set safeboot network
The Operation completed successfully.
c:\WINDOWS\system32>shutdown -r -f -t 0
Manually it was working (run in safeboot) but when I tried through code Windows restarted, but not in safeboot.
How to make this work both 32 bit and 64 bit operating system ?
Do you run your program with the system() call as an administrator? I would not expect that call to succeed if you do not.