Killing outgoing TCP sessions

Posted on 2006-04-13
Last Modified: 2008-03-04
Hello all,

We have a windows 2003 server. This server is running some scripts for the clients. Theese scripts are leaving connections open, to much connect. Windows Xp cannot have more then 10 server connections.

What I want , I want to kill all TCP connections as quick fix. I can do this though disabeling and enabling the network card or rebooting.
I want to disable and enable scripted the network card. But I don't know how.

As final solution we will rewrite all the script to resolve all problems, but this takes to long.

PLease help me..
Question by:Nostradamuz
    LVL 15

    Accepted Solution

    If the clients are using DHCP, you could try the following:

    ipconfig /release
    ipconfig /renew

    If that doesn't work, you'll need to use netsh -
    LVL 23

    Assisted Solution

    You are saying that the script connects to an XP machine, and the XP becomes the "server connection" at that point?  Which is why you are limited to 10 client connections to that XP box, right?

    Just making sure, since you are also talking about 2003 server in your post.

    Any script that will disable and renable the NIC obviously has to be run locally on the XP workstation in question, since once you disable it, you won't be able to re-enable it remotely (since you won't be able to get to it).

    That said, here's two scripts.  One using simple net commands, the other vbscript.  All that needs to be done is to stop and start the Server service on the XP workstation.  That will kill any client connections to that box.

    SCRIPT #1: (save as batch file and run on the XP machine.)

    net stop server
    net start server

    (that's it, lol)

    SCRIPT #2: (save as .vbs and run on the XP machine)

    Option Explicit
    Dim objShell, intShortSleep, intLongSleep
    Dim strService
    Set objShell = CreateObject("WScript.Shell")

    ' Values set
    strService = " Server"
    intShortSleep = 1500
    intLongSleep = 5500

    ' Cmd prompt opened
    objShell.Run "cmd"
    Wscript.Sleep intShortSleep

    ' Service stopped with 'Net' command
    objShell.SendKeys "net stop" & strService
    Wscript.Sleep intShortSleep
    objShell.SendKeys "{Enter}"
    Wscript.Sleep intLongSleep

    ' Service started with 'Net' command
    objShell.SendKeys "net start" & strService
    Wscript.Sleep intShortSleep
    objShell.SendKeys "{Enter}"
    Wscript.Sleep intLongSleep

    ' Cmd prompt exited
    objShell.SendKeys "Exit"
    Wscript.Sleep intShortSleep
    objShell.SendKeys "{Enter}"

    Wscript.Echo strService & " service restarted"


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
    Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now