Link to home
Start Free TrialLog in
Avatar of jonathanx
jonathanx

asked on

who connected to my machine script

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.
ASKER CERTIFIED SOLUTION
Avatar of matteo_vaccari
matteo_vaccari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of matteo_vaccari
matteo_vaccari


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
Avatar of Deepak Vasudevan
Hi:

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

deepak
Avatar of jonathanx

ASKER

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.
hahaha.. ok my fault. noting happens bcoz nobody was connected to my pc. Both script works fine. :P

haha.. thanx!