SkillPilotAI

net

net.exe is the classic all-in-one Windows command: it maps and browses shares (client side), publishes shares and shows sessions and open files (server side), and manages services, time, password policy, users and groups. It is built into every Windows and runs in CMD and PowerShell.

198.1 Why is it used?

  • One tool for SMB connections, shares, services and accounts, available on every Windows without installs.
  • Creating shares, adding users or starting/stopping services needs Run as administrator.
  • On the office domain PC only net help was run; other outputs come from Microsoft docs and a Samba lab on Linux.

198.2 How it works

Who net talks to
  1. 1.net use Z: \\srv\share on your PC

  2. 2.Workstation service (LanmanWorkstation) acts as the SMB client

  3. 3.Request travels on TCP 445 to the file server

  4. 4.Server service (LanmanServer) serves the share

  5. 5.On the server: net session = who is connected, net file = what is open

  6. 6.net start / net stop talk to the Service Control Manager

198.3 net help

Output
net help                :: all 19 sub-commandsnet help use            :: help for one commandnet help use | more     :: one screen at a timenet use /?              :: short syntaxnet helpmsg 2250        :: explain an error number
Output
C:\> net helpmsg 2250The network connection could not be found.

198.4 net use: connect / disconnect shares

Command Prompt
net use                                   :: list connectionsnet use Z: \\srv\share                    :: map a drivenet use * \\srv\share *                   :: next free letter, password promptnet use Z: \\srv\share /USER:CORP\alicenet use Z: \\srv\share /PERSISTENT:YES    :: reconnect at next logonnet use Z: \\srv\share /REQUIREPRIVACY    :: encrypted SMB onlynet use Z: /DELETEnet use * /DELETE /Y                      :: all drives, no promptnet use H: /HOME
OptionMeaning
/USER:CORP\alice | alice@corp.example.comdomain\user or UPN form
/SAVECRED, /SMARTCARDsave credentials / use smart card
/REQUIREINTEGRITY, /REQUIREPRIVACYrequire signed / encrypted SMB
/TCPPORT, /QUICPORT, /RDMAPORTalternate port instead of 445
/TRANSPORT:TCP|QUIC, /SKIPCERTCHECKSMB over TCP or QUIC
/REQUESTCOMPRESSION, /BLOCKNTLM, /WRITETHROUGHcompression, block NTLM, no cache
/DELETE, /GLOBAL, /HOME, /PERSISTENT:YES|NOremove, all-users mapping, home dir, reconnect at logon
Command Prompt
net use e: \\financial\lettersnet use m: \\financial\letters\User2net use f: \\financial\public /deletenet use k: "\\financial 2" \memosnet use /persistent:yes
  • Linux side of the same job (Samba lab, filesrv 192.168.218.10): smbclient lists and downloads files; a wrong password gives NT_STATUS_LOGON_FAILURE.
Terminal
smbclient //filesrv/docs -A /lab/asha.auth -c lssmbclient //filesrv/docs -A /lab/asha.auth -c 'get notes.txt /tmp/n.txt'cat /tmp/n.txtsmbclient //filesrv/docs -U asha%WrongPass -c ls
Output
$ smbclient //filesrv/docs -U asha%WrongPass -c lssession setup failed: NT_STATUS_LOGON_FAILURE

198.5 net view: browse computers and shares

  • net view = computers of the domain/network; net view \\fileserver = its shares; /ALL shows hidden shares like C$; /DOMAIN lists domains/workgroups; /CACHE shows offline caching.
  • On Linux, smbclient -L and Samba's net rpc share list do the same.
Terminal
smbclient -L //filesrv -A /lab/asha.authnet rpc share list -S filesrv -A /lab/root.authnet rpc user -S filesrv -A /lab/root.authsmbstatus -bsmbstatus -S
Output
$ net rpc share list -S filesrv -A /lab/root.authdocspublicIPC$$ net rpc user -S filesrv -A /lab/root.authasharoot$ smbstatus -bPID     Username     Group        Machine                                   Protocol Version76      asha         asha         192.168.218.20 (ipv4:192.168.218.20:37586) SMB3_11$ smbstatus -SService      pid     Machine       Connected atdocs         76      192.168.218.20 Mon Nov  9 12:34:12 2026 UTC

198.6 Server side: net share, net session, net file

Command Prompt
net sharenet share DataShare=c:\Data /remark:"For department 123."net share Data=C:\Data /GRANT:Everyone,READ /USERS:10net share DataShare /deletenet sessionnet session \\192.168.1.10 /DELETEnet filenet file 42 /CLOSE
Output
Share name   Resource                        Remark-------------------------------------------------------------------------------ADMIN$       C:\windows                      Remote AdminC$           C:\                             Default shareIPC$                                         Remote IPCpublic       C:\publicUsers        C:\UsersThe command completed successfully.
Output
Computer      User name        Client type  Opens   Idle time------------------------------------------------------------------------\\BWESTON       CHRISDR          Windows 7       1       00:00:13\\JAMESMC-01    Administrator    Windows Vista   0       01:05:13
  • net share: /GRANT:user,READ|CHANGE|FULL, /USERS:N or /UNLIMITED, /REMARK, /CACHE:Manual|Documents|Programs|BranchCache|None, /DELETE; can share a printer port (LaserPrn=LPT1:).
  • net session (server only): /DELETE closes a session and its open files; /LIST as list. Linux equivalent: smbstatus -b / -S (asha on SMB3_11, using docs).
  • net file: shows ID and locks of open files; net file ID /CLOSE frees the locks.

198.7 statistics, config, time, start/stop

Command Prompt
net statistics WORKSTATIONnet config WORKSTATIONnet time \\dc01 /SETnet start                     :: running servicesnet start "DHCP Client"       :: 2+ words need quotesnet stop SPOOLER && net start SPOOLERnet stop SERVER               :: cancels all file sharing
Output
C:\> net help timeNET TIME[\\computername | /DOMAIN[:domainname] | /RTSDOMAIN[:domainname]] [/SET]NET TIME synchronizes the computer's clock with that of another computeror domain, or displays the time for a computer or domain.The /QUERYSNTP and /SETSNTP options have been deprecated. Please use w32tm.exeto configure the Windows Time Service.
  • net statistics / net config WORKSTATION show SMB client counters and PC name, domain, user (not run on the office PC).
  • net time /DOMAIN uses the PDC; /QUERYSNTP and /SETSNTP are deprecated: use w32tm.
  • net start knows built-in names like SERVER, WORKSTATION, SPOOLER, NETLOGON, "DHCP CLIENT"; any installed service (W32Time) works too.

198.8 accounts, user, group, localgroup, computer, print

Command Prompt
net accounts /MINPWLEN:12 /MAXPWAGE:90 /UNIQUEPW:5net user alice * /ADDnet user alice /ACTIVE:NOnet user miked /time:M-F,08:00-17:00net user alice /WORKSTATIONS:PC01,PC02net group "Domain Admins" /DOMAINnet localgroup Administrators alice /ADDnet localgroup "Remote Desktop Users" CORP\alice /ADDnet computer \\grizzlybear /add
Output
Force user logoff how long after time expires?: NeverMinimum password age (days): 1Maximum password age (days): 90Minimum password length: 8Length of password history maintained: 5Lockout threshold: 4Lockout duration (minutes): 4Lockout observation window (minutes): 4Computer role: WORKSTATION
CommandScopeTypical use
net accountspassword/logon policy/MINPWLEN, /MAXPWAGE, /UNIQUEPW, /FORCELOGOFF; domain policy wins on joined PCs
net useruser accounts/ADD, /DELETE, /ACTIVE, /EXPIRES, /TIMES, /WORKSTATIONS (max 8), /HOMEDIR
net groupdomain global groupsneeds /DOMAIN; list or add/remove members
net localgroupthis PC's local groupsAdministrators, Remote Desktop Users; DOMAIN\user for domain accounts
net computerdomain computer accounts/ADD or /DEL, run on a DC
net printprint queue jobsdeprecated since Windows 7: use PowerShell

198.9 Common mistakes

  • Mapped drive disappears after restart: map with /PERSISTENT:YES.
  • Empty net view does not mean no shares: plain net view uses the SMB1 browse list, which is mostly disabled. Ask the server directly (net view \\server, smbclient -L).
  • Forgetting quotes for multi-word service names (net stop "DHCP CLIENT").
  • Typing passwords on the command line instead of * (prompt).

198.10 Interview tips

  • net use = client side (Workstation service), connects a remote share; net share = server side (Server service), publishes a folder.
  • Both use SMB on TCP 445; net session and net file show who is connected and what is open.
  • /PERSISTENT:YES keeps mappings across logons.
  • Add /DOMAIN to user/group/accounts to act on the DC.
  • net helpmsg <number> explains an error code.