Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
June 6, 2005
If you are plagued with a file server that doesn't disconnect idle sessions, you probably experience slowing performance and/or the connection limit is exceeded.
I have scripted IdleDisconnect.bat to disconnect sessions that have been idle for two or more hours.
You can schedule IdleDisconnect.bat to run daily, or multiple times per day.
IdleDisconnect.bat contains:
@echo offsetlocal ENABLEDELAYEDEXPANSIONfor /F "Tokens=1-8*" %%a in ('net session^|Find "\"') do ( call :sess %%a %%b %%c %%d %%e %%f %%g %%h %%i @echo !comp! !idle!)endlocalgoto :EOF:sessset comp=%1set idle=00:00:00:sessLshiftif {%1}=={} goto sessTset idle=%1goto sessL:sessTfor /f "Tokens=1 Delims=:" %%x in ('@echo %idle%') do ( if "%%x" GTR "01" net session %comp% /DELETE)
You May Also Like