8

I need to connect to a network share with path \\192.165.24.175\04_Top_Image and need to use cmd to cd into it, but I don't know how to cd into it.

I know how to go from C: to D:, but it doesn't work for a network share, and while I've tried to look this up, I can't find anyone talking about it.

Tuor
  • 273
  • 1
  • 13
ToMakPo
  • 215
  • 3
  • 10
  • 2
    so right now, this isn't a network drive. this is just a share you have browsed. to make it a network drive, you need to Map it to a drive letter on the local system, using the explorer shell integration ("Map Network Drive") or a command like `net use`. that will assign it a drive letter that you can CD into. – Frank Thomas Feb 04 '22 at 18:55
  • When writing questions and answers, it's important the correct markdown is used so the content displays correctly _(please see the formatting bar)_. When the context is code-based and requires a monospaced font, it should be encapsulated within single _(a short character string)_ or triple _(code box)_ backticks so code content renders correctly _(`\ ` are a special character for markdown as it tells the markdown system to exclude certain characters from markdown formatting, and when `\\ ` are used outside of the monospaced code markdown, the markdown system will only render a single `\ `)_ – JW0914 Feb 04 '22 at 19:19
  • An alternative is to not use `cd` but instead to store the directory in a cmd variable and supply the full path at all times. – Ben Feb 05 '22 at 20:17
  • 1
    Alternative solutions here also: https://superuser.com/questions/282963/browse-an-unc-path-using-windows-cmd-without-mapping-it-to-a-network-drive – jpa Feb 06 '22 at 10:47

3 Answers3

13

I need to connect to a network drive with path \\192.165.24.175\04_Top_Image

One or all of these methods should work, as once mapped, you can cd to it just like any folder or access it via the Explorer tree:

  • Open Explorer and browse to the Network Section to see if you see the folder; if so, open it and answer any credential requirements

  • In Explorer, open the left side tree so you can see Network, then right-click on it and select Map Network Drive
    • In sub-window, enter the drive letter (your choice) and in the folder box: \\192.165.24.175\04_Top_Image
    • Click on connect, answer any credential requests, and it should connect

  • Using command line:
    NET USE  X:  \\192.165.24.175\04_Top_Image
    
JW0914
  • 7,052
  • 7
  • 27
  • 48
John
  • 46,167
  • 4
  • 33
  • 54
  • 1
    Isn't File Explorer is irrelevant to their question?? they stated they need to use the command prompt, specifically. – jrdnjhntsn Feb 04 '22 at 19:03
  • 7
    I would say that providing instructions for both cli and gui is "value add" for the answer. no reason not to mention it, and it does contribute to the discussion., – Frank Thomas Feb 04 '22 at 19:16
  • 4
    @jrdnjhntsn While an OP may specify they're only looking for this or that way, when an answer includes both a GUI and CLI approach, it's beneficial to others who may come across the questions or answer in the future, as unless deleted, questions and answers will remain on the site for decades. – JW0914 Feb 04 '22 at 19:28
9

you could/should map the location properly;

net use DriveLetter: NetworkPath /PERSISTENT:YES

then you can just cd into the directory.

or using the the pushd command is an option;

pushd YourNetworkPath

I believe Powershell will just let you use the cd command though, so if you aren't married to cmd.exe, you could use powershell too.

jrdnjhntsn
  • 351
  • 1
  • 11
  • PowerShell has several default aliases, with `cd` aliased to [`Set-Location`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-location?view=powershell-7.2) _(same as `ls`, which is aliased to [`Get-ChildItem`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7.2))_, however `cd` in PowerShell is not the same as [`cd`](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cd) in a cmd terminal. – JW0914 Feb 04 '22 at 19:22
5

Use pushd \\192.165.24.175\04_Top_Image. It will map the drive and cd into it. When you're done, use popd to unmap and go back to where you were.

Jonathan
  • 3,459
  • 5
  • 27
  • 35