The Computer Oracle

How do I change to a mapped network drive at the command line?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 2 Looping

--

Chapters
00:00 How Do I Change To A Mapped Network Drive At The Command Line?
00:27 Accepted Answer Score 55
00:58 Answer 2 Score 5
01:20 Answer 3 Score 4
01:33 Answer 4 Score 0
01:53 Answer 5 Score 0
03:23 Thank you

--

Full question
https://superuser.com/questions/221620/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows #commandline #networkdrive

#avk47



ACCEPTED ANSWER

Score 55


You need to make sure that the drive is mapped under the user which is running the command prompt. Try typing net use U: and see what info it gives you. If it's not showing the drive as being mapped, try remapping the drive (net use U: \\servername\share\path\).

You can also try changing directories by using cd /d U:, rather than just U:. This won't help you though if the network path doesn't exist.




ANSWER 2

Score 5


CD if in the user account where drive is mapped.If you are in a Elevated Command you are no longer in the mapped user account.

Win 7: net use U: \servername\share\path\

win 8: pushd \servername\share\path\




ANSWER 3

Score 4


In case you're using Windows 8 the pushd command will help you

pushd u:

Source: How to cd to a network drive on Windows 8?




ANSWER 4

Score 0


Windows PowerShell in Administrator mode will allow you to perform MS-DOS Commands you are looking for.

Open Windows PowerShell... Type CD ...

Ex.

PS C:\> CD U:\

PS U:\>

Hope that helps.




ANSWER 5

Score 0


If the drive is already mapped: u:

If you get the error you say, then it is not mapped. You will need to know the path to the network share.

With the path to the share you can use either:

net use:

net use by itself shows your current drive mappings.

To map a drive:

net use u: \\server\share\subfolder

This will not switch yet, which you can then do with u:. It will also persist beyond the current command session. Though it may not persist between logins.

There is a global setting for whether to persist new drive mappings between logins that can be toggled with:

net use /persist:yes or net use /persist:no

You can also specify this flag when adding a new mapping:

net use u: \\server\share\subfolder /persist:yes

This will affect the drive you're adding and any new drives you add from then on (if /persist is omitted).

/persistent:yes can be shortened to /p:y (and /p:n for no).

pushd:

pushd \\server\share\subfolder

This will create a temporary drive mapping to the share using an arbitrary letter. It will automatically switch to the drive and folder. It will automatically be disconnected either by using popd or else when the current command line exits.