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.
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 2010 '
----------------------------------------------------' 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 & "$".
Guy
Recommends: Permissions Analyzer - Free Active Directory Tool
I like the
Permissions 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.
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.
The 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.
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems.
Fortunately, Solarwinds
have created the
Free WMI Monitor so that you can actually see and understand these gems of
performance information. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.