Scroll To Top

How to Share Files Using Command Line in Windows?

Posted in Articles, Networking, Windows1 year ago • Written by Shais9 Comments

To share files using command line and manipulating is faster and more professional then GUI. Networking task has many command line utility which works like a charm. With the following command line guide, you can do more than share files using command line.

Preferably, you need to know the basic of command line interfaces. In Windows you can do it with command prompt or Powershell. Both of them works perfect to this article. I prefer to use Powershell rather than command prompt. Some commands are really need to execute in Powershell.

How to Share Files Using Command Line?

It’s not just sharing files. You should enable network discovery, enable firewall, viewing shared files, and connecting to share folder or create a map network drive. So let’s do it step by step with Windows PowerShell.

1. Change Computer Name with Command

When your Windows installation has finished, at the final step ask you set a name. In the network if the computer name is not related to computer, it should be change to find it easy. The Rename-Computer powershell command work exact for changing a computer name.

Firs type “hostname” command to know the current computer name. Then type “Rename-Computer -NewName Win10 -Restart” and press enter.

Change a Computer Name with Command Line

Change a Computer Name with Command Line

In command, Win10 is the new name of my computer. The –restart switch will restart the system after renamed.

2. Assign IP Address with Command

A computer in a network need to have an IP address like a mobile with a number. Assigning IP address to a computer, preform with Netsh command. I refer you to “Configure Windows IPv4 Networking with Netsh” article. Assigning IP address is covered clearly.

3. Creating Folder with Command

Creating folder is not just performed with right click and select New then Folder. Command line has few command to create a folder or directory. So let’s do it with mkdir or md command.

While Powershell is opened, type “dir” to list all directories of the current path. Then type

Create a Folder with Command Line

Create a Folder with Command Line

A folder named “ShareFolder” has been created. Type “dir” or “list” to see the created folder.

List Directory with Command Line

List Directory with Command Line

The “Ls” command is not work on command prompt, instead use dir.

4. Share a Folder with Command

Now the folder is created successfully and need to share for network. Before sharing a new folder, once type “net share” command to see what is shared currently on your system. Type net share and press enter.

What is Shared on My Computer

What is Shared on My Computer

There is nothing shared currently on this computer. So to share a folder, type “net share NetworkFiles=C:\SharedFolder /grant:everyone, full” then press enter.

Share Files Using Command using PowerShell

Share Files Using Command Line with PowerShell

  • The NetworkFiles is the share name of SharedFolder which previously created with command.
  • The /grant:everyone,full assign shared permission to everyone’s group. You can assign /change or /read permission.

Note: When you assign permission, you must specify the group name or a user name.

Type “net share” to see the result.

Shared Folders on My Computer

Shared Folders on My Computer

Well don, the folder has been created and shared successfully. Now go to the next step, enabling network discovery services with command.

5. Enable Network Discovery with Command

Network discovery is a network setting that affects whether your computer can find other computers and devices on the network and whether other computers on the network can see your computer. By default, Windows Firewall blocks network discovery, but you can enable it with command.

To enable network discovery, type “netsh advfirewall firewall set rule group=”Network Discovery” new enable=Yes

Enable Network Discovery with Command Line

Enable Network Discovery with Command Line

The Firewall rules are updated. Now the network discovery is enabled and you should see the computer’s name when executing “net view” command.

View Network Computers with Command Line

View Network Computers with Command Line

Net view is another useful command line utility which shows network computers.

6. Connect to Shared Folders with Command

Now I’m on another Windows which is Windows 8.1. I’m trying to connect to shared folder’s of Windows 10 through network with command line.

While you are on the other computer on the network, type “net share” to  see network computers

Net View Command

Net View Command – Share Files using Command

Both Windows 10 and Windows 8 are in the same network. Type “net view \\Win10” to see the shared folders of Windows 10.

So let’s connect to shared folders of Windows 10 form Windows 8. Type “net use Y: \\Win10\NetworkFiles” then press enter to create a network map drive for NetworkFiles folder.

Connect to a Shared Folder with Command Line

Connect to a Shared Folder with Command Line

Here is the result of executing “net use” command. It show network map drives. Read more about net use command on How to Create Map Network Drive In Windows 10 and Server? article.

Network Map Drives

Network Map Drives – Share Files using Command

Navigate to drive Y: and see what files the Windows 10 folder has?

See the Shared Folder's Contents

See the Shared Folder’s Contents – Share Files using Command

Let’s copy some files from shared folder to our computer with command. It performs by
“copy” command. Type “copy ‘Windows 10 Reports.txt C:\Users\Shais\Desktop” then press enter.

Copy the Shared Files to other computer with Command Line

Copy the Shared Files to other computer with Command Line

See the Windows 10 Reports text file has been copied to my desktop on Windows 8. You can copy files with copy command. But to copy a full directory with it’s contents, use “xcopy” command.

That’s all share files using command line. Hope you find this article helpful and replay to this question. Command line is simple or hard?

Comment us your answer about share files using command and etc. It will help use to create more beneficial and helpful articles.


TAGS: , , , , ,
About this Author
Shais

I'm a network and Information Security instructor. Here is my online pictorial notebook. I would like to write and share my experience through this website for computer enthusiasts and technology geeks.

Like us on Facebook
on Facebook
Shais

Follow me on Twitter
Follow @technigs on Twitter
Shais
Add me on Google+
on Google+
Shais

9 Comments so far. Feel free to join this conversation.

  1. KararNovember 9, 2015 at 6:24 pm - Reply

    That’s one of the best articles that I wanted.

    • Shais
      ShaisNovember 9, 2015 at 11:20 pm - Reply

      OK, I’m glad you find the article helpful. Please share to promote the articles with your friends on Social media networks.

  2. Mukhtar JafariNovember 10, 2015 at 11:08 am - Reply

    how to assign IP Address with command line I didn’t Understood can you explain it please????

  3. SchemaJune 17, 2016 at 1:01 pm - Reply

    This article really helped me. Thanks a lot. Keep up with the gOod work.

  4. GokulnathNovember 14, 2016 at 6:06 pm - Reply

    how can we able enable windows 10 firewall blocks after disabling it????

    • Shais
      ShaisNovember 14, 2016 at 11:01 pm - Reply

      Hi Gokulnath,

      Just add NO instead of YES at the end of this command “netsh advfirewall firewall set rule group=”Network Discovery” new enable=Yes”

      netsh advfirewall firewall set rule group=”Network Discovery” new enable=no

  5. GokulnathNovember 15, 2016 at 7:58 am - Reply

    that was really help full thanks…
    Is there a way to transfer files between PC and Android by using cmd without using any software??

  6. Henri LordMarch 6, 2017 at 11:40 pm - Reply

    how do i sort out system error 5 because im running as admin on both computers and it still says ‘system error 5 has occurred’? thanks in advance

Leave A Response