The NET command is used to manage open files and user sessions.
Syntax NET SESSION [\\computername [/DELETE] | /LIST] NET FILE [id [/CLOSE]] Key computername A computer whose shared resources you want to view. /DELETE End the session and close all open files for that session, if computername is omitted all sessions are ended. /LIST Display information in a list rather than a table. id The identification number of the file. /CLOSE Close an open file and remove file locks
Administrator privileges are required to run the NET SESSION command, if run from a non-elevated session it will return an ERRORLEVEL = 5 Access is Denied.
You can also use NET sessions or NET sess to run NET session.
NET SESSION requires the Server service to be running.
To create file shares the SERVER service must be running, which in turn requires 'File and Print Sharing' to be installed.
Display all the open shared files on a server and the lock-id:
NET FILE
Close a shared file (disconnect other users and remove file locks) type this command from the server where the file is shared:
NET FILE id /CLOSE
List all sessions connected to this machine:
NET SESSION
or
NET SESSION | Find "\\"
List sessions from a given machine:
NET SESSION \\ComputerName
Disconnect all sessions connected to this machine:
NET SESSION /DELETE
Disconnect all sessions connected to this machine (without any prompts):
NET SESSION /DELETE /y
Disconnect sessions from a given machine:
NET SESSION \\ComputerName /DELETE
NET SESSION displays incoming connections only, in other words it must be run on the machine that is acting as the server.
“Never mistake activity for achievement” ~ John Wooden
NET.exe - Manage network resources.
NET USE - connect to a file share.
OPENFILES - List or disconnect open files, local or remote.
PsFile - Show files opened remotely.
PsLoggedOn - Who’s logged on.
Q149427 - Change Password from the CMD prompt.
Equivalent PowerShell: Get-CIMinstance win32_share or the Get-NetSession function (no elevation needed).
Equivalent bash command (Linux): who currently logged in.