1

I am trying to set up a system where when my pc goes to sleep or shutsdown it sends an HTTP request to a raspberry pi on my local network which then performs some actions. Currently I have written a batch script that sends the HTTP request and this bat file is set to run on kernel-power eventid 42 using task scheduler. This event is triggerd when the pc goes to sleep. At first no HTTP request was being sent at all, and I realised that was because when the pc goes to sleep, the network adapter is disabled so in my bat file the first thing it does is enable the network adapter, then waits 5 seconds then sends the HTTP request before waiting 2 seconds and then turning the network adapter back off again. With this change made, nothing happens when the pc goes to sleep, however the HTTP request is put in a queue i guess because as soon as the pc comes back on again the request is sent... which in fairness is some progress lol. Anyway I have no idea how to make this work and so I would really appreciate some help because this is such a seemingly simple problem. Thanks in advance

5
  • You have to ensure that your script runs before it goes to sleep. So basically disable the automatic sleep function and setup something that does the same, but instead of putting your pc to sleep, it runs your script. Your script then does the http request, waits 1 minute and then goes to sleep.
    – LPChip
    Commented Jun 3, 2022 at 12:56
  • hi, thank you for your commend, how do i disable the automatic sleep function? thanks Commented Jun 3, 2022 at 13:28
  • Power management.
    – LPChip
    Commented Jun 3, 2022 at 13:32
  • im really sorry, I am going to need more detail than that, how exactly do I disable the automatic sleep function? Commented Jun 3, 2022 at 18:26
  • Open Settings -> System -> Power management, and disable it. Or right-click start menu -> Power Management.
    – LPChip
    Commented Jun 3, 2022 at 22:20

0

You must log in to answer this question.

Browse other questions tagged .