JSI Tip 9426. How can I disconnect idle sessions from a server than don't automatically disconnect?

Jerold Schulman

June 6, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


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)



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.

You May Also Like