Categories: Files

How to disable File Sharing

In Windows, one can share files to other users in the same network using SMB protocol. We can disable sharing of a folder/drive from command prompt using net share command.

Open elevated windows command prompt and run the below command.

C:\>net share
Share name   Resource                        Remark
-------------------------------------------------------------------------------
C$           C:\                             Default share
IPC$                                         Remote IPC
ADMIN$       C:\WINDOWS                      Remote Admin
The command completed successfully.

To disable sharing C$, run the below command

C:\>net share C$ /DELETE
C$ was deleted successfully.

An alternative option is to disable file sharing on the computer. This disables sharing for all folders.

net stop lanmanserver

Example:

C:\>net stop lanmanserver
The following services are dependent on the Server service.
Stopping the Server service will also stop these services.

   Computer Browser

Do you want to continue this operation? (Y/N) [N]: y
The Computer Browser service is stopping...
The Computer Browser service was stopped successfully.

The Server service is stopping.
The Server service was stopped successfully.

Now if you list the network shares, you would get message that the server is not running.

C:\>net share
The Server service is not started.
Is it OK to start it? (Y/N) [Y]: n
C:\>
Srini

View Comments

  • Thanks! I sometimes have to connect to LAN outside home/office network and the command helps shutoff all share folders

Share
Published by
Srini

Recent Posts

Add new user account from command line (CMD)

Adding users from command line is much easier than going through the UI. It saves…

4 years ago

Delete directory from command line [Rmdir]

Do you want to delete a directory from Windows command prompt(CMD)? This post explains how…

4 years ago

TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do…

4 years ago

Kill Chrome from command line

Chrome is definitely the stable browser compared to other ones and it has been my…

4 years ago

Find windows OS version from command line

Windows has multiple command line utilities that can help find the version of the Windows…

4 years ago

How to check if Windows 32 or 64 bit?

There are multiple ways to check whether a Windows computer is running 32-bit OS or…

7 years ago