Safekill OBS with a batch script

1

I would like to create a batch script that safely closes OBS Studio without corrupting a streaming session. This thread discusses closing a program with TASKKILL, but when I tried it it didn't work. Their examples referenced Windows XP, is it different for Windws 10? These are the scripts I used following their example:

TASKKILL /FI "C:\Program Files (x86)\obs-studio\bin\64bit\obs64.exe"

and

TASKKILL /FI obs64.exe

A term I've seen before was called "safe" killing. Can this be done with a batch script, and if so, how?

Mr. Mendelli

Posted 2017-04-07T08:01:58.407

Reputation: 1 061

What scenario do you have that would require you to kill it using a script? Depending on the recording format, as the options would tell you, it's important to properly stop the recording in order to not corrupt the recording. As per taskkill /? you would either need the PID or image name. So your second version should work to kill the task. As you're not using wildcards you could just skip the /FI flag. – Seth – 2017-04-07T08:09:20.007

I have OBS running on a separate machine, and would like to make ending my streams much easier, it's basically just going to be a shortcut to going to the other machine, and manually closing it there. I don't know what a "wildcard" is (I'm still fairly new to programming). I also don't mind if the script brings up the save work prompt. I just want a safe remote kills-witch. – Mr. Mendelli – 2017-04-07T08:28:50.277

This doesn't really have anything to do with programming. A wildcard is a placeholder. E.g. you could use ob* to kill all processes that match, where * represents any number of characters. If you want to execute taskkill remotely you will have to specify /S and possibly /U and /P. Just run taskskill /? and look at the examples. OBS is a rather complex application it might be better to manually stop it. You could just use something like remote desktop to access the other PC. – Seth – 2017-04-07T08:33:38.343

Ok, but what does /FI do anyways? – Mr. Mendelli – 2017-04-07T08:43:56.787

taskskill /? what don't you understand about the description? – Seth – 2017-04-07T08:57:52.887

Answers

2

If you would actually just go ahead and read the available help text for taskkill by either running taskkill /? or looking for the online documentation, you would see what each switch does and also get a few examples.

To actually see the output of taskkill /? you will have to open a command line window beforehand.

Both outputs will show you that, in order to kill a remote process, you will have to run something like taskkill /s computer /u user /p password /im obs64.exe. It's up to the program to decide how it handles SIGTERM.

Seth

Posted 2017-04-07T08:01:58.407

Reputation: 7 657

Thanks for your input, I'll just tinker with this some more to fine-tune it. – Mr. Mendelli – 2017-04-07T09:36:54.950