-2

I use OBS as a replay buffer on my machine. For that purpose it is always started when I log on. OBS also is started as an admin because the recording is choppy otherwise.

This setup generally works, the only problem is that OBS prevents my PC from going into sleep while the replay buffer is active. For this purpose I wanted to create a new shortcut that kills OBS and then sends my PC to sleep.

I created the following script, which is started with admin rights with the same task scheduler task that starts OBS.

RWin & Y::
  Run, *RunAs cmd.exe taskkill /f /t /im "obs64.exe"
  DllCall("PowrProf\SetSuspendState", "int", 0, "int", 1, "int", 0)
Return

However when I press RWin and Y OBS survives. I've tried a few solutions so far (that I sadly deleted and thus can't show), but they all either didn't kill OBS or required a seperate input (like confiriming that the script may change my computer).

Is there any way to reliably kill a programm that desperatly doesn't want to be killed?

jonas
  • 27
  • 4

1 Answers1

0

If you run the AHK script as administrator the result should be successful.

if not A_IsAdmin{
        Run *RunAs "%A_ScriptFullPath%"
        ExitApp
    }

LWin & Y::
Process, Close, obs64.exe
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 1, "int", 0)
return