1. Home
  2. Windows Tips
  3. Access network location in command prompt on windows 10

How to access a network location in Command Prompt on Windows 10

The Command Prompt is one of two stock terminal apps you’ll find on Windows 10. The other is PowerShell and there are quite a few differences between the two. Command Prompt has been around much longer than PowerShell and it stands to reason that more people use it. With Command Prompt, you can move to any directory on your system, and run commands in it. You might run into a slight problem if you’re trying to move to a folder with a space in the name but there’s a simple trick to it.

If you’re trying to access a network location in Command Prompt, the cd command won’t do the job. In fact, the error message that you get might lead you to believe you cannot access a network location in Command Prompt and run commands in it. That isn’t true. You just need to use a different command for the job.

Network location in Command Prompt

When you use the cd command and follow it up with a network location, Command Prompt tells you that ‘CMD does not support UNC paths as current directories’. A quick search will tell you that a UNC path is a path with double slashes or backslashes which is what a network path has.

To move Command Prompt into a network directory, you need to use the pushd command. First, get the complete path to the network location you’d like to access. In the screenshot below, the complete path to the folder that’s open in File Explorer is;

\\MACBOOKAIR-5B8A\Mac\Users\fatimawahab\Pictures

The path is not simply Z:\ which is what you get if you try and copy it from the location bar.

Once you have the path, run the following command. Enclose the path in double-quotes if there is a space in the path.

Syntax

pushd network-path

Example

pushd \\MACBOOKAIR-5B8A\Mac\Users\fatimawahab\Pictures

You will notice that Command Prompt allocates a different drive letter to the network location than the one you see in File Explorer. This isn’t anything to worry about.

If you’re wondering how this works in PowerShell, you don’t need to. PowerShell will let you switch to a network location with the cd command.

Syntax

cd "path-to-network-location'

Example

cd \\MACBOOKAIR-5B8A\Mac\Users\fatimawahab\Pictures

Unlike Command Prompt, PowerShell does not have trouble with UNC paths. If you like, you can just use PowerShell instead of Command Prompt. It is different from Command Prompt but it isn’t less powerful. In fact, you’ll find that in many cases, the above case being a good example, PowerShell is easier to work with.

1 Comment

  1. Remember, m’am, we always like to know how to undo anything we do on our computers.

    The pushd command you show us (many thanks) creates a new drive letter, Z: (‘zed’) in this case – but you don’t say how we remove it.
    As it happens, I found that as soon as I closed the command window, the drive disappeared.