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
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'.
Pre-requisites - 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:)
' 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 PointsNote 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 & "$".
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.
See Also● Logon Script Home ●
Add Error Correcting Code ● Multiple Mapped Network Drives |