kill net session

話說 , 現在公司辦公室裡用的 printer server 是一部 Win2K Pro , 機器老舊也就算了, 因為它是 Win2K Pro , 很容易因為已建滿 10個 connection 而令別人不能再玩 ! …

btw , 可以用下面這段 VBScript code, 透過行程, 每2~5分鐘跑一次, 可以砍掉線上idel 的session :


\'2005/06/21 Written by Worren@CMO

	
   Dim WshShell,WshShell2, i
   Dim f_idle
   Dim strBUF,strBUF2, pathNET
   
   pathNET = \"c:winntsystem32net \"

   Set WshShell = CreateObject(\"WScript.Shell\")
   Set oExec = WshShell.Exec(pathNET & \" session\")
   
   Set WshShell2 = CreateObject(\"WScript.Shell\")
   
   strBUF=\"\"
   strBUF2=\"\"
   f_idle = False
   
   Do While oExec.StdOut.AtEndOfStream  <> true
           strBUF = oExec.StdOut.ReadLine		
          If Left(strBUF,2)=\"\" Then
              f_idle = False
              If Int(Right(split(strBUF,\":\")(0),2)) > 0 Then f_idle = True
              If Int(split(strBUF,\":\")(1)) > 3 Then f_idle = True
              If f_idle=True Then
                   strBUF2 = pathNET & \" session \" & split(strBUF,\" \")(0) & \" /DELETE /Y\"
                   WshShell2.Exec(strBUF2)       	 
                   WScript.Echo strBUF2
              End If
          End If
   Loop


Share your vote!


Do you like this post?
  • Fascinated
  • Happy
  • Sad
  • Angry
  • Bored
  • Afraid

Leave a Reply

Your email address will not be published. Required fields are marked *


Please help to input verification code