Windows execute command before sleep / on power button press - windows

I want my power button to send a HTTP request before going to sleep.
I already set a task to execute with trigger System/Kernel-Power/42 but the task executes after the next wake rather than before sleep.
Also autohotkey doesn't seem to log the power button neither does a windows trigger.
Is it possible to delay windows sleep? I could not find a way to do that.
Thanks

So it's not a real answer but I came up with a solution:
If the wifi hotspot is turned on (I need it anyways) while my pc goes into sleep mode, it sends a System/Kernel-Power/59 and turns the monitor off.
I now have a task that listens for this and executes what I want, then turns the hotspot off and then turns the pc into sleep mode.

Related

Check if process is hung via bat file

So we are running a Pandora on a specific pc to feed music to our phone lines. Every so often the program times out with "Are you still listening" or " Cant connect to the internet". In both instances all we need to do is to click the radio button and it resumes fine. The problem is as it only feeds the phone lines we never know when it has hung.
Currently I am closing and restarting Pandora thru a task at timed intervals. But as those conditions happen randomly as far as I can tell I still end up with no music for 1/2 to 45 min.
However in both instances when that occurs the Processor and memory usage is "0%". So what i think I can do is check to see if the Memory and processor usage both = 0 and if so I can then close and restart the applet.
I have tried several power-shell and bat scripts but I have not been successful.
Can anyone assist?
Thanks
-EDS
It is not circumventing business licensing. We are a paid subscriber.

Windows CMD/Power Shell sleep's when i do not interact

I use the power shell a lot to run react-native aplications and Android emulators. But every time i have to open the shell and press enter to wakeup the shell, because aparrently it stops running or lose priority when i do not interact with it for some time.
So, there's some way to prevent the cmd from stop processing my tasks?
Other people have reported this as an issue but it turned out to be user error. I can only assume that you have the same problem.
Chances are that quickedit mode is on and you have somehow clicked in the window thus freezing the process.
See this post on serverfault
And this post on MS technet

Is There a Way to Auto-close 'App Has Stopped Responding' Messages?

I have a simple batch script running constantly on a Windows 10 PC at work that performs relatively simple tasks over and over again throughout the day, basically testing certain server diagnostics while I'm working on it.
Every once in a while, the program will crash, so I have another program I downloaded that will auto-start up the program if it does crash and close.
However, there is one scenario where instead of the program just crashing and closing completely, a message box will pop up saying the program has stopped responding, with a 'Close Program' button. In this case, the auto-start program I have thinks the program is still running, so it won't attempt to re-run the batch script.
Is there a way to auto close the program when it crashes this way, or something that will automatically click the 'Close Program' button for me when it appears?
I suspect the messages comes out when the main thread hangs for too long. It may be cleaner to spawn another thread to take care of expensive / slow computation, Windows should not bother to kill the main thread (and your program) in first place like that.

Use different shell based on which device woke the PC?

I'm trying to accomplish the following:
When my PC is woken from sleep with the Steam Controller, it lunches directly into Steam Big Picture Mode, without showing the Windows desktop first.
Ideally I'd like to be able to exit from Steam BPM back into Windows desktop, without having to start explorer.exe manually. So explorer.exe should be running in the background, I think.
Could anybody suggest how I could go about this?
You could attach a script to the wake-up event, then have your script check wake-up source and if it's Steam controller, launch Steam in Big Picture mode.
This is general outline. The burden of implementation, falls on your shoulders.

Emulate Sleeping Windows Mobile Device

Is it possible to emulate a device sleeping and waking using the Microsoft-supplied device emulators?
Yes, but you have to generate your own emulator image with a modified kernel (changing OEMPowerOff). Bruce Eitman blogged about it here. You didn't detail your needs, so it's hard to say, but you might be able to provide some form of simulation by manually setting the named power management events.
This is an old thread, but in case anyone else stumbles across it, you can make the Windows Mobile emulators 'sleep' and wake up, though not with the debugger attached.
Close the emulator window while your application is running and save the state. Or, configure power management to sleep the emulator at the desired time; the emulator will close and save its state automatically. If the debugger is attached, it will lose its connection and stop debugging.
Open Device Emulator Manager and click Refresh until the emulator shows up as disconnected (no icon next to it). Right-click on the emulator name and select Connect.
Emulator wakes up and reappears. If your application is listening for the wake-up notification, it will be signaled at this point.
You can also wake up the emulator using Debug > Attach to Process, though this does not always succeed. Either way, by the time the debugger attaches, the wake up sequence will already have executed. If you can get by with debug statements, though, this is easier than modding the emulator image.

Resources