1

I'm running Windows 7 64 bit Home Premium.

My new internet connection is a bit buggy, and I need to keep reconnecting. To make sure my computer keeps connected while I'm away, I created a script that reconnects every 30 minutes. Since it runs constantly, I wanted to make it run hidden, and found a working way: solution 1 on this answer.

However, without the command window, I'm not sure how to go about stopping the script when I need to. What I'm doing is looking up the cmd.exe process in the task manager and stop it, but I keep wondering: Is this a good way? Is there a better, more direct way, that doesn't require the task manager?

Sampaio
  • 257

2 Answers2

1

You could always just make another batch file to kill the first.

In your first batch file make sure you add:

@Echo Off
title batchname.bat

That way, in the second batch file you can kill it by calling:

taskkill /f /im cmd.exe /fi "windowtitle eq batchname.bat"

Source, provided by Sampaio.

Michael Frank
  • 8,091
  • 3
  • 43
  • 54
0

An easier Task Manager method would use

schtasks /create /sc minute /mo 30 /tn "30 Minute Script" /tr \path\to\30min.vbs

  • and the last line of 30min.vbs sets up a new 30 minute job, to execute 30 minutes hence.

When you don't need it any more, kill the "30 Minute Script" with

schtasks /end /tn "30 Minute Script"

K7AAY
  • 9,725