on error resume next 
set arg=wscript.arguments 
If arg.count=0 then 
wscript.echo "use:// cscript.exe FS.vbs port" 
sleep 1000 
wscript.quit 
End If 
Tport=arg(0) 
Runs=false 
While runs=false 
Dim oShell,oExec,strOut,oRegExp,Matches,Match,Num,Tport 
Set oShell = WScript.CreateObject("WScript.Shell") 
Set oExec = oShell.Exec("netstat -an") 
Set oRegExp = new RegExp 
oRegExp.Pattern = "TCP[\s]+[\d\.]+:"&Tport&"[\s]+[\d\.]+:[\d]+[\s]+ESTABLISHED" 
oRegExp.IgnoreCase = True 
oRegExp.Global = True 
Do While Not oExec.StdOut.AtEndOfStream 
strOut = strOut & oExec.StdOut.ReadLine() & Chr(13) & Chr(10) 
Loop 
Set Matches = oRegExp.Execute(strOut) 
Num = 0 
For Each Match In Matches 
Num = Num + 1 
Next 
if num > 1 then 
Runs=true 
oShell.run "logoff" 
end if 
Set Matches = Nothing 
Set oRegExp = Nothing 
Set oExec = Nothing 
Set oShell = Nothing 
Wend