Jump to content

I am trying to close idle net sessions on a Windows 7 machine I have found a script that is su...


G+_Wesley Robinson
 Share

Recommended Posts

 

I am trying to close idle net sessions on a Windows 7 machine. I have found a script that is suppose to delete the idle sessions after 59 mins, but it doesn't seen to be working and I have no idea how to read this script. Can someone enlighten me on what is going on with this script. I have tried to comment out the portion that sets the Idle time to 00:00:00, but I would also like to set that idle time to 00:58:00 so I wouldn't have to wait an hour to test the delete session script. Thanks for the help. Here is the code that I have:

 

@echo ON

setlocal ENABLEDELAYEDEXPANSION

 

for /F "Tokens=1-8*" %%a in ('net session^|Find "\\"') do (

call :sess %%a %%b %%c %%d %%e %%f %%g %%h %%i

@echo !comp! !idle!

)

endlocal

goto :EOF

 

:sess

set comp=%1

set idle=00:00:00

:sessL

shift

if {%1}=={} goto sessT

set idle=%1

goto sessL

 

:sessT

 

for /f "Tokens=1 Delims=:" %%x in ('@echo %idle%') do (

if "%%x" GEQ "00" net session %comp% /DELETE /Y

)

Link to comment
Share on other sites

 Share

×
×
  • Create New...