diff --git a/oem/install.bat b/oem/install.bat index 018c510..9a1b208 100644 --- a/oem/install.bat +++ b/oem/install.bat @@ -23,3 +23,20 @@ if %ERRORLEVEL% equ 0 ( ) else ( echo Failed to create scheduled task. ) + +REM Create time sync task to be run by the user at login +copy %~dp0\TimeSync.ps1 %windir% +set "taskname2=TimeSync" +set "command2=powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -File \"%windir%\TimeSync.ps1\"" + +schtasks /query /tn "%taskname2%" >nul +if %ERRORLEVEL% equ 0 ( + echo %DATE% %TIME% Task "%taskname2%" already exists, skipping creation. +) else ( + schtasks /create /tn "%taskname2%" /tr "%command2%" /sc onlogon /rl HIGHEST /f + if %ERRORLEVEL% equ 0 ( + echo %DATE% %TIME% Scheduled task "%taskname2%" created successfully. + ) else ( + echo %DATE% %TIME% Failed to create scheduled task %taskname2%. + ) +)