Is there a command in which we can see list of shared directories and with whom they are shared for windows 7?

Solution 1:

How do I get a list of shared directories (and whom they are shared with)?

net session will give you the information you are looking for.


Net session

Manages server computer connections. Used without parameters, net session displays information about all sessions with the local computer.

Syntax

net session [\\ComputerName] [/delete]

Parameters

\\ComputerName : Identifies the computer for which you want to list or disconnect sessions.

...

Use net session to view the computer names and user names of users on a server, to see if users have files open, and to see how long each user's session has been idle.

The information appears in a format similar to the following:

Computer      User name        Client type  Opens   Idle time
-------------------------------------------------------------
\\BASSETT     CHRISDR          Windows 2000   1     00:00:13
\\SHARONCA    Administrator    DOS LM 2.1     0     01:05:13

To display one user's session, use ComputerName with the command. The information about a single user includes a list of shared resources to which the user has connections.

Source Net session


Disconnect a user or users

For example, to disconnect a user on a computer named user_computer, which is connected to a shared folder that you are managing, type:

net session \\user_computer /delete

...

Syntax:

net session \\<computer> /delete

where:

  • Net session Lists or disconnects users connected to shared folders on the computer.
  • \\<computer> The name of the computer accessing the shared folder.
  • /delete Ends the session, and closes all open files on the computer for the session. If you omit \computer, the command ends the sessions on the local computer.

Source Disconnect a User


Further Reading

  • An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
  • net - The NET Command is used to manage network resources.