Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared Access 1

Status
Not open for further replies.

ekbranson

Programmer
Jan 12, 2004
52
US
I am trying to find a way to determine who is accessing a shared folder. Similiar to MS Computer Management -> Shared Folder -> Sessions. I have looked at WMI's Win32_Shares and several other classes but I can't seem to find anything that I can use.

Basically what I would like to do is to enumerate all users/computers loged in to a shared drive on a Win2k machine. Any Ideas?
 
Hello Ekbranson,

In IADsResource, the documentation explains that
IADsResource said:
When a remote user opens a folder or a subfolder on a public share point on the target computer, ADSI considers this folder to be an open resource and represents it with a resource object that implements this interface.
Try this skeleton see if it answers at least partially to your need. If not check out the documentation for details.
Code:
sHost="a1b2c3"    'the host of the share
set fsvc=getobject("WinNT://"& sHost & "/LanmanServer")
set cResources=fsvc.Resources
for each oResource in cResources
    with oResource
        wscript.echo .path & vbTab & .lockcount & vbcrlf & .user
    end with
next
set cResources=nothing
set fsvc=nothing
regards - tsuji
 
Thanks for your response, I am currently looking into ADSI. However, I am not that familiar with active directory. The computer I would like to manage is a resource on a active directory domain. I am not sure if this would provide what I need.

Basically what I have is a computer (not a server) that has a shared hard drive. At 12:00 AM I perform a scheduled backup from that harddrive to a network drive. I currently send out a netsend message to all computers that could be acessing this drive, informing the users to close out of all documents. What I would like to do is send messages to only those computers that are currently viewing the harddrive and not all the computers.

Thanks again.
 
If the computer is sharing as a directory or drive, then it is acting as a server in this context. Have you tried the code that was posted? It worked splndidly for me. A star for tsuji for teaching me something new. As usual.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Thats exactly what I needed, I guess every day you learn something new.

Thanks alot
 
Here is what I came up with incase it can be of use to anyone else.

Code:
dim strMyComputer

strMyComputer = "YOURCOMPUTER"
set fso = GetObject("WinNT://YOURDOMAIN/" & strMyComputer & "/LanmanServer")
for each oFso in fso.sessions

	sendMessage oFso.Computer

next 

set fso = nothing

sub sendMessage(strClientComputer)

	Const WindowStyle = 0
	Const WaitOnReturn = False
	
	Dim strCommand, strMsg, sNetSend
	Dim oSh
  
	On Error Resume Next

	strMsg = "YOURMESSAGE"
	strPathNetSend = "%COMSPEC% /C %SystemRoot%\system32\NET.EXE SEND"
	strCommand = strPathNetSend & " " & strClientComputer & " " & strMsg

	set oSh = CreateObject("WScript.Shell")
	osh.Run strCommand, WindowSyle, WaitOnReturn
	set oSh = Nothing
end sub
 
Thank you for posting your complete solution. Hopefully it will be of help to someone in the future.

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top