0

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.

Bali C
  • 30,582
  • 35
  • 123
  • 152
udb
  • 3
  • 1
  • 2

2 Answers2

1

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
Bali C
  • 30,582
  • 35
  • 123
  • 152
0

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

Community
  • 1
  • 1
Stephen Wrighton
  • 36,783
  • 6
  • 67
  • 86
  • thanks for your reply. please tell me how to check if the program is running and then run the script. – udb Jan 12 '13 at 20:21