Shared folders open sessions

Posted on 2011-04-26
Medium Priority
Last Modified: 2012-05-11
Hi everyone,

I have a problem with a server with one of my customers, The sessions of the shared folders always stays open. I can terminate the open sessions with the following script, but I only want to kill the sessions which have no open files.

How should you modify the following script that it only terminates the connections with no open files?

The server is a windows small business server 2003.

Thanks in advance!

Kind regards
Set objConnection = GetObject("WinNT://sbsserver/LanmanServer")
Set colSessions = objConnection.Sessions

For Each objSession in colSessions

Open in new window

Question by:Silencer001

Expert Comment

ID: 35471089
What value do you have set for the sessions to timeout?

Accepted Solution

spinzr0 earned 1000 total points
ID: 35471162
This should do it.  The Resources collection gets all users who have an open file.  Then it terminates any user without an open file.
Set dResources = CreateObject("Scripting.Dictionary")
Set oConnection = GetObject("WinNT://sbsserver/LanmanServer")

Set cResources = oConnection.Resources
For Each oResource in cResources
    If Not dResources.Exists(LCase(oResource.User)) Then dResources.Add LCase(oResource.User), 1
Set cResources = Nothing

Set cSessions = oConnection.Sessions
For Each oSession in cSessions
    If Not dResources.Exists(LCase(oSession.User)) Then _
Set cSessions = Nothing

Set oConnection = Nothing
Set dResources = Nothing

Open in new window


Author Comment

ID: 35473662
Wow worked like a charm, really pro stuff!!

Thank you so much!

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question