Reputation: 3
I want to close a program using Windows task scheduler, so I've created a batch file:
TASKKILL /F /IM "Mobile Partner.exe"
This script closes the application "Mobile partner" and this trick is working!
My question - is it possible to run this script only if "Mobile Partner" tries to start or the computer is connected to the internet?
Thanks.
Upvotes: 0
Views: 5875
Reputation: 31231
This will kill the process if it is either running or there is an internet connection.
tasklist /nh /fi "imagename eq Mobile Partner.exe" | find /i "Mobile Partner.exe" >nul && taskkill /im "Mobile Partner.exe" /f
ping www.google.co.uk -n 1
if %errorlevel%==0 taskkill /im "Mobile Partner.exe" /f
Upvotes: 1
Reputation: 37839
yes in a manner of speaking. The script would run on the schedule regardless. What you're wanting is to only run the kill command under your conditions.
Here's a SO question about pinging an ip, which could be used to determine if you're connected to the internet How to check if ping responded or not in a batch file
as for the other, that's a matter to just see if the process 'Mobile partner' is active (a simple WMI call).
Upvotes: 0