1

Intermittently I'm finding that net use doesn't feel like seeing the server in front of it.

The following commmand works:

pushd \\place\otherplace\1.2.0\

Windows explorer also consistently brings me where I want to go.

For some reason, though, the following sometimes returns that the path doesn't exist.

net use R: \\place\otherplace\1.2.0\

What's the difference in implementation for net use?

SeanVDH
  • 866
  • 1
  • 10
  • 28
  • Questions on professional server- or networking-related infrastructure administration are off-topic for Stack Overflow unless they directly involve programming or programming tools. You may be able to get help on Server Fault. – Sébastien Temprado Apr 11 '18 at 19:42
  • This is not a question about how to configure a server, I'm asking after the difference in implementation behind the bash commands after noticing a discrepancy in the behavior. You may feel that bash isn't "real programmer" enough for this site, but there are almost 100k questions tagged with it. – SeanVDH Apr 11 '18 at 20:14
  • 2
    Are you sure you're using bash `pushd` -- with backslash as the path separator? bash `pushd //place/otherplace/1.2.0` would simply set that location as the process working directory. Windows has no problem with UNC paths as the working directory. The CMD shell has a problem, so CMD's `pushd` command will automatically map "\\place\otherplace" as a logical drive letter. It's similar to what "net.exe" does, though they might not go about it in exactly the same way. But first you need to clarify whether you're actually using CMD's `pushd` command. – Eryk Sun Apr 11 '18 at 21:30
  • No, you're right. I'm using the CMD `pushd` command. I'll update. – SeanVDH Apr 12 '18 at 13:12

2 Answers2

2

The practical difference, for anybody writing a script that may come across this, is that pushd and windows explorer both accept \\path\to\directory\

net use fails with a trailing slash, and requires \\path\to\directory

SeanVDH
  • 866
  • 1
  • 10
  • 28
  • For anybody coming across this that is outraged by the fact that `net use` fails with a trailing slash, fear not - `net use` will succeed with a trailing slash **AND** a period. I haven't tested with `pushd`, but there is a very specific situation I needed `net use` instead of `pushd` and `\\path\to\directory\.` works and is much simpler to implement than removing the slash (in most cases I'm guessing) – immobile2 Oct 18 '21 at 19:31
0

Basic difference between pushd and net use command is that user gets to choose desired Drive letter in case user needs to right more scripts on that particular Network Drive.

On the other hand, using pushd in scripts, a user is able to use that drive as well just like cd command.

Keep in mind that the PushD command allocates drive letters from Z: on down and will use the first unused drive letter that it finds.

Vishesh
  • 133
  • 3
  • 11
  • For reference: https://www.techrepublic.com/blog/windows-and-office/use-the-pushd-popd-commands-for-quick-network-drive-mapping-in-windows-7/ – Vishesh Jun 30 '19 at 01:39