How to mount Windows share from command line (cmd.exe) on Microsoft Windows XP / Vista / 7

MS Windows net command mount map attach command how to windows xp 7 and vista, mount share name with net cmd
I’m rarely using computer from a Windows host, but sometimes I need to as well. I’m not a big fan of M$ Windows, Microsoft and their products. Though to be truthful lately their OS has improved significantly. BTW from purely “it works” perspective Windows 7 is quite succesfully made OS. Windows 7 is hard to infect with Viruses, looks to me it works much more stable compared to XP and so on. Well anyways back to my topic. I write this post just to shortly show how one can mount a share in Windows Command Line (cmd.exe)

In all Windows NT based Windows OSes (except maybe some Home releases), the way to attach / mount a Windows Network Share (Samba share / SMB share – as we Linux users call it) is done with command:

  • net

The net command has many options, but most important ones in most cases are:

net view – Using to list a share content

C:> net view \ /All
Shared resources at \
Share name Type Used as Comment
ADMIN$ Disk Remote Admin
C$ Disk Default share
NETLOGON Disk Logon server share
SYSVOL Disk Logon server share
The command completed successfully.

As you see in above output, net view \IP_ADDRESS /All or net view \ lists every Shared folder on a host.
Once you have the list choose of possible mount points, you can easily map / mount share by opening Windows command line, cmd.exe (Quickest way I know of is press simultaneously Windows button + R (key) and typing in command prompt:

C:> net use h: \NetworkShare.Domain-name.comShare-Name
Shared resources at \

BTW sometimes administrators forget to set password to Administrator account, it is generally good rule of thumb if you’re in position to check your Windows Sharing server security by trying intruding with adminsitrator user:

C:> net user administrator admin

Hopefully if you set a password for your Administrator you will get:

C:> net user adminsitrator admin
System error 5 has occcured.
Access is denied.

If you need to login to a ShareName from command line on Winblows with certain username use:

net use d: \server-share-nameshare /USER:UserName

Just change Username with whatever username you need …

If the “Domain name” is created so it contains few words without a space you will need to Connect the Windows Share putting windomain name in “” :

C:> net use k: "\share name with spaces name"Users


Removing mapped Share is done with:

C:> net use f: \share-namepublic /delete

Another useful net variation is to once for all map a Share, just like you have option from Windows Control Panel -> Network and Sharing Center

c:> net use k: "\whatever share name"Users
C:> net use /persistent:yes

Then whilst restart-ing Windows PC on next boot K: Drive will be mapped to “whatever share name”Users

net command is among the swiss army knife tools of Windows crackers, hence I think any person interested in Windows Security or supposed to write .VBS logon scripts for Windows DomainController should check it (if not already) 🙂

net supports also to send a password directly from command line (very bad idea from security perspective):

C:> net use * \remotepcshare /u:domainnameusername password

The meaning of * character above is to map the network drive in the last free one drive letter on the system. Lets say that last Drive Letter mounted on the Win host is W:/, then net use * will automatically assign the new drive a letter corresponding to consequential letter Z:

Here is complete syntax as pointed from Microsoft resources net cmd documentation:

net use [{DeviceName | *}] [\ComputerNameShareName[volume]] [{Password | *}]] [/user:[DomainName]UserName] [/user:[DottedDomainName]UserName] [/user: [UserName@DottedDomainName] [/savecred] [/smartcard] [{/delete | /persistent:{yes | no}}]

net use [DeviceName [/home[{Password | *}] [/delete:{yes | no}]]

net use [/persistent:{yes | no}]

net command is one of the most important commands for the Windows SysAdmin. It gives one access to add / delete / modify existing users and many, many more. If you want to learn a bit more on Windows Command Line or interested in Windows Scripting, I suggest you check out net docs thouroughfully
That’s all hope this post helps someone.

Share this on:

More helpful Articles

Download PDFDownload PDF

Tags: , , , ,

4 Responses to “How to mount Windows share from command line (cmd.exe) on Microsoft Windows XP / Vista / 7”

  1. Courtney Vinup says:
    Firefox 3.5.3 Firefox 3.5.3 Windows XP Windows XP
    Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv: Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)

    I like what you guys are up also. Such smart work and reporting! Carry on the excellent works guys I¡¦ve incorporated you guys to my blogroll. I think it’ll improve the value of my web site 🙂

    View CommentView Comment
  2. says:
    Firefox 5.0.1 Firefox 5.0.1 Windows XP Windows XP
    Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1

    you're really a good webmaster. The site loading pace is incredible. It sort of feels that you are doing any unique trick. Also, The contents are masterwork. you have done a excellent activity on this subject!

    View CommentView Comment
  3. XP liker says:
    Firefox 62.0 Firefox 62.0 Windows 8.1 x64 Edition Windows 8.1 x64 Edition
    Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0

    in XP,  command line only, no mouse.

    net share BBB=M: makes all users to have full control,  that was all XP could give me.

    is there a way in XP or some untility to make net share BBB=M: read only for users in command line?



    View CommentView Comment

Leave a Reply

CommentLuv badge