I run Matlab simulations that sometimes take weeks to finish and when Windows restarts I lose all my work so I really need a way to stop auto restarts.
Windows 11 seems to have disabled all ways to get around Auto Update Restarts. Existe-t-il un still a workaround?
It used to be possible to set NoAutoRebootWithLoggedOnUsers in:
Windows will not reboot during working hours. My solution is to run a tâche planifiée that changes the working hours in le registre, say every hour or two, so that it is always a working hour. I coded up this 4 line cmd command batch file program:
`for /f %%i in (‘powershell “((get-date).Hour+18) %% 24”’) do set startHour=%%i
for /f %%i in (‘powershell “((get-date).Hour+12) %% 24”’) do set endHour=%%i
I then used Windows Planificateur de tâches to make this .bat script run every hour for 1 day and repeat daily.
To stop pop-ups of the command windows, make task scheduler start the program/script "cmd.exe"
and put as its arguments:
`/c start /min C:\work\disableautoupdate.bat ^& exit`
(Substitute your own filename above for C:\work\disableautoupdate.bat)
Cela va minimise the window your script runs in.
**Tested: Ça fonctionne!** J'ai installé an update requiring a restart on 31-May. I am informed that this restart will happen outside of working hours. As of 20-June, 22 days later, no restart had taken place.
I figured out how to incorporate @Jonathan's feedback. It is easier to do modulo maths (and to get the hour independent of locale/region/format preferences) with powershell commands. It's still a cmd batch file, but it calls powershell. Reduces to 4 lines and should work everywhere.