Files

67 lines
1.7 KiB
Batchfile
Raw Permalink Normal View History

2021-11-10 20:18:27 -05:00
@echo off
2022-07-14 13:25:37 -04:00
setlocal
2021-11-10 20:18:27 -05:00
cls
set /a REBOOT=0
2022-07-14 13:25:37 -04:00
echo.
echo Configuring required services to automatically start in Safe Mode with Networking.
2023-12-15 13:07:33 -05:00
call :configure-service Syncro
call :configure-service SyncroLive
call :configure-service SyncroOvermind
2022-07-14 13:25:37 -04:00
call :configure-service SplashtopRemoteService
2024-05-15 11:43:05 -04:00
call :configure-service "Cloud Backup Service Remote Management"
2021-11-10 20:18:27 -05:00
2022-07-14 13:25:37 -04:00
:schedule-normal-reboot
2021-11-10 20:18:27 -05:00
call :reset-errorlevel
2022-07-14 13:25:37 -04:00
echo Configuring system to reboot into Normal Mode at next reboot
2024-05-15 11:43:05 -04:00
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce" /v "*RestartNormalMode" /t REG_SZ /d "bcdedit /deletevalue {current} safeboot" /f > nul 2>&1
2021-11-10 20:18:27 -05:00
if %ERRORLEVEL% GTR 0 (
2022-07-14 13:25:37 -04:00
set /a REBOOT=%REBOOT%+1
2021-11-10 20:18:27 -05:00
echo ERROR: could not configure reboot into normal mode
2022-07-14 13:25:37 -04:00
)
:configure-reboot-safemodewithnetworking
call :reset-errorlevel
2024-05-15 11:43:05 -04:00
bcdedit /set {current} safeboot network
2022-07-14 13:25:37 -04:00
if %ERRORLEVEL% GTR 0 (
2021-11-10 20:18:27 -05:00
set /a REBOOT=%REBOOT%+1
2022-07-14 13:25:37 -04:00
echo ERROR: could not restart into Safe Mode with Networking
2021-11-10 20:18:27 -05:00
)
2022-07-14 13:25:37 -04:00
:reboot
if %REBOOT% EQU 0 (
shutdown /r /f /t 5
goto :end-success
)
2021-11-10 20:18:27 -05:00
goto :end-error
2022-07-14 13:25:37 -04:00
:configure-service
2021-11-10 20:18:27 -05:00
call :reset-errorlevel
2022-07-14 13:25:37 -04:00
sc query | findstr /I "SERVICE_NAME: %*" >nul
2021-11-10 20:18:27 -05:00
if %ERRORLEVEL% EQU 0 (
2022-07-14 13:25:37 -04:00
echo Enabling %* to startup in Safe Mode with Networking
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\%*" /f
) else (
set /a REBOOT=%REBOOT%+1
echo ERROR: could not configure %* service to start in Safe Mode with Networking
2021-11-10 20:18:27 -05:00
)
2022-07-14 13:25:37 -04:00
goto :EOF
:reset-errorlevel
cmd /c "exit /b 0"
goto :EOF
:end-success
echo Successfully scheduled a reboot into Safe Mode with Networking
exit /B 0
goto :end
2021-11-10 20:18:27 -05:00
:end-error
echo.
echo Errors were encountered and the system will not be restarted
echo Please make sure this script is run with administrative privileges
2022-07-14 13:25:37 -04:00
exit /B %REBOOT%
2021-11-10 20:18:27 -05:00
goto :end
2022-07-14 13:25:37 -04:00
:end