net use vs susbst

0

There are many questions on stackexchange asking for a persistent across reboot functionality, and the answers point either to registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices or psubst.

It seems to me that superficially at least a similar effect can be achieved using persistent mapped network drive, for example the second command below can replace the first; they both allow access to c:\<path> using the shorter X:

psubst X: C:\<path>
net use X: \\localhost\C$\<path>

What are the circumstances under which mapping a network drive will not work?

Miserable Variable

Posted 2013-03-25T23:08:46.990

Reputation: 759

Answers

0

Not everyone has access to the dollar sign shares. By default, only administrators do.

Edit: They are also not available on home editions of Windows, from what I read.

Patrick Seymour

Posted 2013-03-25T23:08:46.990

Reputation: 7 662

1When did that change. Before they used to work precisely the same way, except that due to a bug they did not show up when you browsed to a computer. (Later that bug changed into a design feature). – Hennes – 2013-03-25T23:16:28.063

1@Hennes: I thought $ shares were always hidden by design. – user1686 – 2013-03-25T23:18:30.037

2Been that way since at least NT 4. That is why they are called administrative shares: they are for admins. – Patrick Seymour – 2013-03-25T23:19:53.730

@grawity I wish I had a good source to point to. Esp since this may be an urban legend. But the way it got explained to me is that it initially was an 'undocumented feature'. At that time I was new to windows and struggling with win95 and ghost, so NT 4 time seems about right. – Hennes – 2013-03-25T23:22:38.210

Thank you, looking for a solution for myself I had not considered that the shares may not be available to all – Miserable Variable – 2013-03-25T23:54:34.307

1

A couple things come to mind why you might have an issue with the net use command

  1. you are assuming the user has access to the administrative shares. By default this is an admin only share.
  2. You are assuming the shares are enabled. If the administrative share was turned off, this wont work.
  3. You are assuming networking itself is properly working. Its possible that networking could be broken, localhost is redirected somewhere else, etc..

These scenarios arent likely, but could happen.

Using the net use command is taking unnecessary steps that would be avoided with psubst.

Keltari

Posted 2013-03-25T23:08:46.990

Reputation: 57 019