I would like to run a script in Windows right before standby/sleep mode with admin rights and blocking, i.e., the system should not go to sleep until the script has successfully terminated.
Alternatively, it would be possible for me to create a background process or service if it can be done in a simple manner.
Background: It seems I have a very buggy driver for a device which leaves Windows hanging with a blank screen when going to standby or presents a blank screen upon wakeup. This is not 100% reproduceable, it happens only sometimes. However, it seems when I just disable the corresponding device in the device manager, everything works fine. I would like to automate this process.

