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 $ Scenario:
- Example – MapNetworkDrive to Hidden $
- More than two Drives?
- PowerShell Logon Script
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.
Our objective is to map the J: to a folder called ‘\home\user$’ on a server called ‘\\alan’.
- On Line 10 change the server name from ‘\\alan’ to your server name.
- Make sure that your server has a share called ‘\home’.
- 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
- Copy and paste the script below into notepad or get a script editor such as OnScript (free download).
- Change the server name from "\\alan to the name of your server.
- Save the file with .vbs extension e.g. MNDDollar.vbs.
- Double click and check in your Windows Explorer for a new drive called :
userxyz$ on ‘alan’ (J:)
‘ VBScript to map a network drive to a hidden share.
‘ Author Guy Thomas https://computerperformance.co.uk/
‘ Version 1.3 – April 24th 2010
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
‘ End of Example VBScript.
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 & "$".
I like thePermissions Monitor because it enables me to see quickly WHO has permissions to do WHAT. When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, takes into account network share access, then displays the results in a nifty desktop dashboard!
Think of all the frustration that this free utility saves when you are troubleshooting authorization problems for users access to a resource. Give this permissions monitor a try – it’s free!
The modern group policy method of drive mapping does not require any knowledge of either VBScript or PowerShell. In Windows Server 2008 you can launch the GPMC and configure Drive Maps in the Preferences section. See more on Group Policy Drive Maps.
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.
If you like this page then please share it with your friends