Note that this script depends on you having your clock settings enabled for 24 hour clock format (i.e. 2pm is 1400). I know this is typically the default for Europe and non-US, but the default recommended settings in the US will be the 12hr format. The script will make incorrect assumptions/calculations with 12 hr format (e.g. when running batch file at 4pm, it set active time 2200 start and 1000 end time, which would make Microsoft think it 6 whole hours where it could initiate a restart, since I ran the batch file at 4:12pm !)
Simple fix - just change your clock to 24hr format and works fine.