Logon Scripts

MapNetworkDrive - Hidden $ Shares

Introduction to Map Network Drive - Hidden $ Shares

To put the case diplomatically, I would not go out of my way to use hidden shares, but if you must have that dollar$ share, then the scripting part is easy.  As far as VBScript is concerned there is nothing special about adding the dollar ($) sign which denotes a hidden share.  If you wish to map to a hidden share, then just treat the dollar sign the same as any other character.

Topics for MapNetworkDrive - Hidden $ Shares

Mapping Hidden $ Shares

If you use hidden shares, for example with users home drives, then just add a dollar to the strRemotePath in the script.  The secret is to create the hidden share correctly on the server.  Should you need to test the existence of the share, try, Start, Run \\ server \hidden$, where hidden$ is the name of the share.

Example - MapNetworkDrive to Hidden $

Our objective is to map the J: to a folder called '\home\user$' on a server called '\\alan'.

Pre-requisites

  1. On Line 10 change the server name from '\\alan' to your server name.
  2. Make sure that your server has a share called '\home'.
  3. Underneath '\home', you have already created a folder which matches the name of the user you are testing.  On this occasion the folder or to be precise, the share has a dollar at the end.  So if the user is called sammy, the share will be sammy$.

Instructions to MapNetworkDrive

  1. Copy and paste the script below into notepad or get a script editor such as OnScript (free download).
  2. Change the server name from "\\alan to the name of your server.
  3. Save the file with .vbs extension e.g. MNDDollar.vbs.
  4. Double click and check in your Windows Explorer for a new drive called :
    userxyz$ on 'alan' (J:)

 

 

' MNDDollar.vbs
' VBScript to map a network drive to a hidden share.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - April 24th 2005
' -----------------------------------------------------------------'
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = "J:"
strRemotePath = "\\alan\home\"
' Purpose of script to create a network object. (objNetwork)
' Then apply the MapNetworkDrive method. Result H: drive
Set objNetwork = WScript.CreateObject("WScript.Network")
' Here is where we extract the UserName
strUserName = objNetwork.UserName
strUserName = strUserName & "$"
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & strUserName

' Extra code just to add a message box
WScript.Echo " Launch Explorer, check: "& strDriveLetter
WScript.Quit

' End of Example VBScript.

Learning Points

Note 1:  As a change from the H: for home drive, this script maps to the J: drive.

Note 2: The script works by taking the username userxyz and concatenating the dollar sign.  What you need is the & "$".

Hidden$ Shares Summary

Technically, there is nothing special about scripting a hidden$ share.  VBScript treats the dollar sign like any other character. In a nutshell, mapping a hidden share is just like another day in the office.


Download my Logon Script eBook for only $6.25

Logon ScriptThe extra features you get in your eBook include, more pages full of detailed examples.  Also, ten 'how to...' sections, with screen shots showing which menus to use.  Go for Guy's eBook - and get a printable version with copy enabled and no expiry date.

  Jumbo Script 7 Package

See Also

Logon Script Home   Add Error Correcting Code   Multiple Mapped Network Drives

^


Google
Web  This website

Solarwinds IpMonitorIs Your Server Running Slowly?

Check with SolarWinds ipMonitor

Analyze your network with ipMonitor.  Get a free evaluation copy, and monitor the performance of the servers on your network.
Free Download of SolarWinds ipMonitor