Solved

who connected to my machine script

Posted on 2004-10-05
5
356 Views
Last Modified: 2008-03-10
im thinking of making a script that display the users connected to my pc (im on a network).
i was able to this using visual basic , using netsessionenum function.

my question is how to i implement this using visual basic script.

thanx.
0
Comment
Question by:jonathanx
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
matteo_vaccari earned 50 total points
ID: 12228216
try this: http://www.microsoft.com/technet/community/scriptcenter/network/scrnet38.mspx

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkConnection",,48)
For Each objItem in colItems
    Wscript.Echo "AccessMask: " & objItem.AccessMask
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Comment: " & objItem.Comment
    Wscript.Echo "ConnectionState: " & objItem.ConnectionState
    Wscript.Echo "ConnectionType: " & objItem.ConnectionType
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DisplayType: " & objItem.DisplayType
    Wscript.Echo "InstallDate: " & objItem.InstallDate
    Wscript.Echo "LocalName: " & objItem.LocalName
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Persistent: " & objItem.Persistent
    Wscript.Echo "ProviderName: " & objItem.ProviderName
    Wscript.Echo "RemoteName: " & objItem.RemoteName
    Wscript.Echo "RemotePath: " & objItem.RemotePath
    Wscript.Echo "ResourceType: " & objItem.ResourceType
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "UserName: " & objItem.UserName
Next
0
 
LVL 1

Expert Comment

by:matteo_vaccari
ID: 12228326

as an alternative, try the following, to enumerate who's connected to your computer's shares.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ServerConnection",,48)
For Each objItem in colItems
    Wscript.Echo "ActiveTime: " & objItem.ActiveTime
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "ComputerName: " & objItem.ComputerName
    Wscript.Echo "ConnectionID: " & objItem.ConnectionID
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "InstallDate: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NumberOfFiles: " & objItem.NumberOfFiles
    Wscript.Echo "NumberOfUsers: " & objItem.NumberOfUsers
    Wscript.Echo "ShareName: " & objItem.ShareName
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "UserName: " & objItem.UserName
Next
0
 
LVL 15

Expert Comment

by:deepaknet
ID: 12234201
Hi:

I think net use command prompt will give details. An API equivalent in VB should help you out.

deepak
0
 

Author Comment

by:jonathanx
ID: 12236301
i've copy & paste both script into a notepad and saved it as a .vbs. i double clicked it and nothing happen.i tried both and nothing happen.

should i change anything in the code,?

thanks guys.
0
 

Author Comment

by:jonathanx
ID: 12236393
hahaha.. ok my fault. noting happens bcoz nobody was connected to my pc. Both script works fine. :P

haha.. thanx!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Basic Java Case or If-Else statement... 3 64
Help Required 3 117
VB.NET String Settings and Temp Folder Question 3 68
what is the best Integrated development environment 2 35
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

685 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