简体   繁体   中英

Closing program using Task scheduler

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.

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM