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
  • 1
  • 5
  • 12
  • 1
    Make another batch file to kill the first? It'd be some kind of brutal process hunger games. – Michael Frank Jan 10 '14 at 01:19
  • 1
    Wi-Fi or wired Ethernet? Please advise. Some radio devices interfere with Wi-Fi on a cyclical basis, especially console gaming headsets. Many, many devices can use the unlicensed Wi-Fi bands and if they are not true Wi-Fi, nothing stops them from putting out radio interference which shreds a Wi-Fi connection. – K7AAY Jan 10 '14 at 01:26
  • @MichaelFrank Good idea, not sure why I didn't think of that. Took me a bit, but got it working with taskkill. If you'd like to rewrite that as an answer, maybe referring to http://stackoverflow.com/q/16513288/2697421 , I would gladly accept it. – Sampaio Jan 10 '14 at 01:33
  • @K7AAY The connection is Wi-Fi, but the reconnection part is done, just looking for a way to kill the script. Thank you for your second comment, but as you can see in my previous comment, I found a way that works best for me (partially because when I use it, I can't stop picturing the "brutal process hunger games", I must admit). – Sampaio Jan 10 '14 at 01:37
  • @Sampaio I'm glad I've create a memory. Be thankful you aren't this guy though: http://thedailywtf.com/Articles/Classic-WTF-A-Crony-Joke.aspx – Michael Frank Jan 10 '14 at 01:41
  • Just stay out of Sector 12. – K7AAY Jan 10 '14 at 01:42

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
  • 7,855
  • 2
  • 39
  • 52
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,512
  • 4
  • 33
  • 62