Map network drive

Lament

Executive Member
Joined
Feb 1, 2010
Messages
7,335
Reaction score
1,386
Location
ლ(ಠ益ಠლ)
Hi,
So I don't know if this is possible, our company has a huge load of shared drives that different clients use, we get a lot of calls and we always have to remote into a machine to map a drive which is stupid and time consuming, what I want is a program/vbsscript that i can email the clients, when they click on the link it must give them a dropdown box with all available drive letters, and next to that an option to enter an network path, or possibly another dropdown box where all the most common shares are located and they can just click on the share and available drive letter and it will map it.
I hope you guys understand what i'm saying.
Creating a batch file is easy enough, and i have no issue in creating 30 batch files for all different possible paths, the problem with batch files is if another drive is already mapped to a drive letter, it will delete that drive letter and replace it with new share.
a typical batch will look like this :

net use T: /delete

net use T: \\FLS001\Share\
Pause
Exit
 
Why dont you actually share the drive on the server?

What do you mean?, this is paths on the server, we have multiple servers with multiple drives and multiple clients. We have our normal share drive that automatically maps via the login scrips that's available across the company. Then we have loads and loads of different folders per department and per client.
 
Like this, then modify who can access what through the policy.

95871702b7.png
 
You using AD? If so you can just use group policies and create a login script for specific user groups.
 
Like this, then modify who can access what through the policy.

95871702b7.png

I know exactly what you are saying, but we are not on the same page at all, I know how to grant access to files and folders, we have MULTIPLE servers, with probably close to 100 different share drives.
If we only had 1 server, then yes I could just control who sees what via folder permissions.
 
Okay,
Lets say group policy wont work, is there an actual VBS file I can use (and edit) that will be able to do what I require?
 
I used to do this batch file **** as logon scripts in the 1990's . surely they have moved on from that?
 
Dis either of you read my post :p
This is exactly what im currently doing, problem is its deleting existing drives.

This should help you out (from the link i posted earlier)

Instructions for mapping to the first available drive letter

Create your network share. Edit the variable strRemotePath on Line 14.
Edit your drive letters in strAlpha = "BJMRU" on line 16.
Copy and paste the script below into notepad or get a script editor such as OnScript (free download).
Save the file with a .vbs extension e.g. FirstLetter .vbs.
Double click the script, read the message box, check drive letters in Explorer. Press F5 to refresh.
' FirstLetter.vbs Windows Logon Script
' VBScript to map the first available drive letter
' Author Guy Thomas http://computerperformance.co.uk/
' Version 3.7 - September 2010
' ------------------------------------------------------'
Option Explicit
Dim strDriveLetter, strRemotePath
Dim objNetwork, objShell
Dim CheckDrive, DriveExists, intDrive
Dim strAlpha, strExtract, intAlpha, intCount

' The section sets the variables
' N.B. Change strRemotePath
strRemotePath = "\\grand\Home"
strDriveLetter = "B:"
strAlpha = "BJMRU"
intAlpha = 0
intCount = 0
err.number= vbEmpty

' This sections creates two objects:
' objShell and objNetwork and then counts the drives
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set CheckDrive = objNetwork.EnumNetworkDrives()

' This section operates the For ... Next loop
' See how it compares the enumerated drive letters
' With strDriveLetter
On Error Resume Next
DriveExists = False
' Sets the Outer loop to check for 5 letters in strAlpha
For intCount = 1 To 5
DriveExists = False

' CheckDrive compares each Enumerated network drive
' with the proposed drive letter held by strDriveLetter
For intDrive = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(intDrive) = strDriveLetter _
Then DriveExists = True
Next
intAlpha = intAlpha + 1

' Logic section if strDriveLetter does not = DriveExist
' Then go ahead and map the drive

Wscript.Echo strDriveLetter & " exists: " & DriveExists
If DriveExists = False Then objNetwork.MapNetworkDrive _
strDriveLetter, strRemotePath
call ShowExplorer ' Extra code to take you to the mapped drive
' Appends a colon to drive letter. 1 means number of letters
strDriveLetter = Mid(strAlpha, intAlpha,1) & ":"

' If the DriveExists, then it is necessary to
' reset the variable from true --> false for next test loop
If DriveExists = True Then DriveExists = False

Next

WScript.Echo "Out of drive letters. Last letter " & strDriveLetter

WScript.Quit(1)

Sub ShowExplorer()
If DriveExists = False Then objShell.run _
("Explorer" & " " & strDriveLetter & "\" )
If DriveExists = False Then WScript.Quit(0)
End Sub

' Guy's First Available Letter Script Example ends here

Learning Points for Mapping to the First Available Drive Letter

Note 1: Trace the outer loop, focussing on strDriveLetter. For a given letter, ask, 'Does this letter = any of the existing mapped network drives?' If yes, then loop and get another letter from strAlpha. If no then success. The script maps that letter because it is free and there is no danger of a conflict.

Note 2: The inner loop is where the script compares strDriveLetter with each drive exposed by the EnumNetworkDrives function.

Note 3: You may prefer to choose a different selection of drive letters for strAlpha. Surprisingly, the list does not have to be in alphabetical order. However, you should not include the letters of local hard drives.

Note 4: Observe the importance of EnumNetworkDrives, and check the plural spelling of this method.

Note 5: The subroutine ShowExplorer() at the end of the script is not strictly necessary, it merely opens the explorer to confirm that the mapped drive now exists.

Challenges : If you take up my theme of developing your own scripts; experiment with different variable names, amend my WScript.Echo messages, add error correcting code, choose different letters to map.
 
it's a vbs script, it will run on windows, not only at logon.

modify it to suit your needs and then run it on your pc to see if it does what it should, then load it into your GPO
 
What do you mean?, this is paths on the server, we have multiple servers with multiple drives and multiple clients. We have our normal share drive that automatically maps via the login scrips that's available across the company. Then we have loads and loads of different folders per department and per client.

This sounds like a problem for Dfs. It's one of the features of Windows Server so you don't have to pay for it. You can build a single virtual share and mount all your existing shares under the structure then users only need to map one drive to the dfs root. If you switch on ABE (access based enumerations), only the shares the user has access to will actually be visible.
 
Top
Sign up to the MyBroadband newsletter
X