Logon Scripts

Guy recommends :
Free Solarwinds
VM Console

Solarwinds VM Console Free Download

Find out which of your VMs are a waste of space and which VMs need more resources.


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 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 ToolFree Permissions Monitor

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.

Download Permissions Analyser - Free Active Directory Tool

 Group Policy Drive MapsGroup Policy Map Drive

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.

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

If you like this page then please share it with your friends

 


See more logon scripts examples

Logon Script Home   • Vbscript Map Network Drive Username   • Multiple Mapped Network Drives

Map Network Drive Script   • Disconnect Network Drives   • Map Network Drive Group

ObjNetwork.MapNetworkDrive   • Logon script group policy  • EnumNetworkDrives

 *


Custom Search

Guy Recommends: WMI Monitor and It's Free!Solarwinds WMI Monitor

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.

Download your free copy of WMI Monitor

 

Home Copyright © 1999-2012 Computer Performance LTD All rights reserved

Please report a broken link, or an error.