Do you read current power management settings before any script processing begins then restore them on exit no matter what PreventPowerSaving calls are made in between?
Yes, that's exactly what the program does. The PreventPowerSaving() command in a script does not read the value again, it only restores the setting to the original value (just like on program exit), or set's it to zero (just like at the beginning of the program). I have now added a test and the program will not set or restore the setting if it is already off. I doubt if it will help, but it will be in the next version and we will see.
What happens if a script abnormally terminates or is killed by task scheduler because it runs too long or by a user in Task Manager?
Then MyDefrag does not get a chance to restore the setting. I asked about this exact possibility in the other thread, but the reply was that the program had never been abnormally terminated or killed.