Question Need to kill processes with task scheduler

Kracov

Member
Jan 26, 2006
52
0
66
kracov.org
I need help to create tasks from batch files that automates things. I'm looking for help to create 2 different things.
1- I use a video converter and after exiting, the process still stays in the task manager. It's not a big problem, but I'd like to create a task that can kill it affter I exit the program or if the process is idle.
2- There's a program called Wallpaper Engine. Whenever I run it, it loads up Steam and occasionally it asks me to update. All I want to do is automate the exiting of Steam 1 minute after starting Wallpaper Engine.
 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
a sysinternals utility called 'pskill' might help you with the first point. The first time you run it, it'll ask you to agree to a licence agreement. From then on it can be used from a script and run automatically.

 

Kracov

Member
Jan 26, 2006
52
0
66
kracov.org
Can you tell me how to configure and run the script? I've had help with scripts before, but I've never created any myself. Just Copy and paste.
 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
The most basic method is a batch file. Create yourself a file with a .cmd file extension, type the commands into the file that you wish to run, then double-click on the file to run the script.

One way to create the file is with Notepad, though that'll stick a .txt extension on the end of the file name, then rename the file (with file extensions visible in Explorer).

pskill is simple to use, e.g.:

pskill processname.exe

It won't ask the process to end nicely, so for example if there's an unsaved file that the 'pskilled' process is handling, you may lose the unsaved changes to that file.
 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
Computer management > task scheduler, I'm just not sure what trigger you intend to use. Why does it have to be scheduled? You could just have an icon on your desktop to force-close the problematic program.
 

Kracov

Member
Jan 26, 2006
52
0
66
kracov.org
Computer management > task scheduler, I'm just not sure what trigger you intend to use. Why does it have to be scheduled? You could just have an icon on your desktop to force-close the problematic program.
Well that's why I created this post. It isn't just these two programs that I want to automate killing. Why click an icon in the Start Menu programs list, when I could just use task manager to kill it? It's not much of a solution.
 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
Well that's why I created this post. It isn't just these two programs that I want to automate killing. Why click an icon in the Start Menu programs list, when I could just use task manager to kill it? It's not much of a solution.
If you're routinely having to do this, a desktop icon is more convenient than the several clicks required to kill it in Task Manager, and these days in Windows there's a couple of hundred processes (is it up to 300 now, I can't remember) to potentially have to scroll past.

If however you try to automate the whole process, then that automation must be managed effectively to ensure that the process doesn't get killed at an inopportune time.

If the video converter program can be scripted, then you could maybe automate it in a batch file then finish it off with pskill. Again though, making sure the automation doesn't throw a spanner in the works is key. A batch file can be used to throw in a couple of basic checking measures, but other scripting engines will give you more features.

I'm kind of curious as to why your initial impression included task scheduler though, it suggested you had at least some familiarity with it.
 

Kracov

Member
Jan 26, 2006
52
0
66
kracov.org
I've asked for help from tech people on forums before, and they helped me to create things that killed processes at certain times. I had one on Windows 7 that killed a process at 4 am everyday. I ended up here because Ars Technica and Discord didn't reply. Help me Mikey, you're my only hope.
 

Kracov

Member
Jan 26, 2006
52
0
66
kracov.org
I'm still hoping that someone can tell me how to make a script or task that can "kill the process if idle for 10 minutes"
 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
I've asked for help from tech people on forums before, and they helped me to create things that killed processes at certain times. I had one on Windows 7 that killed a process at 4 am everyday. I ended up here because Ars Technica and Discord didn't reply. Help me Mikey, you're my only hope.

Yup, task scheduler can definitely do that. Would that help?

I'm still hoping that someone can tell me how to make a script or task that can "kill the process if idle for 10 minutes"
I doubt it, because computationally speaking 'idle' is a pretty vague concept. If your program visibly closes but the process is still visible in Task Manager, it's reasonable to assume that the program hasn't closed because it is still attempting to finish some final task which for whatever reason it never does. Is this program failing to properly close a generally known issue?
 

Kracov

Member
Jan 26, 2006
52
0
66
kracov.org
No, it's not attempting to finish anything. I emailed the support for the video converter, and they said it just hangs around waiting for the next time the converter loads. It's a "helper", not the main converter program. Okay, well I still hope someone knows a program/script that can kill a process by watching whether I exited it. I know it's not an impossibility. I had help making a command line or script that ran another program alongside the running of another one.
 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
No, it's not attempting to finish anything. I emailed the support for the video converter, and they said it just hangs around waiting for the next time the converter loads. It's a "helper", not the main converter program. Okay, well I still hope someone knows a program/script that can kill a process by watching whether I exited it. I know it's not an impossibility. I had help making a command line or script that ran another program alongside the running of another one.
Does the main program work without the helper?

You might construe this response as 'unhelpful', whereas I'm looking for a far easier solution to your problem than the one you're proposing.
 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
Yes. And what is your easier solution? Would it also apply to closing Steam?

One problem at a time. Is the helper set to start when the user logs in to Windows? If so, I'd just stop it doing that. Is it listed in the Task Manager 'Startup' tab (assuming you're running Win10/11)? If so, IIRC you can right-click on it in that list and disable it.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
AutoIt Tool

Join AutoIt forum and ask question there?

 

mikeymikec

Lifer
May 19, 2011
19,943
14,214
136
No, it only runs when the converter runs

I wonder if a very simple batch file that runs the first program then runs pskill helper.exe is all you need.

e.g.:

Code:
"C:\Program Files\Video Converter program\videoconverter.exe"
pskill helper.exe

It looks to me like a batch file will run the first line, wait for that program to close then move to the next line. PsKill needs to be either in the same location as the batch file or stored somewhere listed in the Windows PATH variable. You could drop it into C:\WINDOWS to keep that simple.

One downside is that you'll have a console window open as long as the batch file is running.