Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MAP Drive script 1

Status
Not open for further replies.

solec

IS-IT--Management
Apr 15, 2005
35
0
0
PH
Hi,

Currently some hundred users are manually map to the share of our files server, for example \\tfsphnas01\hello\test, but we are going to migrate to a new files server named \\tfsphsan01, how can i help the hundred users not to remap the drive to the new one but just use a script to remane the old file server currently map in to their worksations? Thanks

solec
 
Check out this site's FAQ's. There is a login script one that is excellent.
 
A login script should be used and preferred....not knowing you conditions and environment...this may help too

(untested)

Code:
Option Explicit

Dim oldSvrName : oldSvrName = "\\OldServerName"
Dim newSvrName : newSvrName = "\\NewServerName"

Dim objNetwork : Set objNetwork = CreateObject("WScript.Network")
Dim colNetDrives : Set colNetDrives = objNetwork.EnumNetworkDrives
Dim intCount, strDLetter, strDPath, strNewPath
For intCount = 0 To colNetDrives.Count - 1 Step 2
	strDLetter = colNetDrives(intCount)
	strDPath = colNetDrives(intCount + 1)
	strNewPath = Replace(strDPath, oldSvrName, newSvrName, 1, -1, vbTextCompare)
' 	WScript.Echo strNewPath
	objNetwork.RemoveNetworkDrive strDLetter, True, True
	objNetwork.MapNetworkDrive strDLetter, strNewPath, True
Next

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Extensively tested...faq329-5798

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Hi Markdmac,

Have tried your add on but its not working,,,...

'This add on allows you to remap a drive letter from one server
'to a share of the same name on another server

Set oFSO = CreateObject("Scripting.FileSystemObject")


'Enumerate the mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
'Now bind to the drive and get the letter and path
Set drive = oFSO.GetDrive (clDrives.Item(i))
ThisDriveArray = Split(drive.ShareName,"\")
'The old server name will be located in ThisDriveArray(2)
'The share name is in ThisDriveArray(3)
'Remap the existing drive To a New server
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
WSHNetwork.MapNetworkDrive clDrives.Item(i), "\\NewServerName\" & ThisDriveArray(3),True
Next



Solec
 
even if you get it working you are just going to constantly unmap then remap at every log to the same end target server.
 
The add on works, it is not a standalone script. It is intended to be put within the red section of the code as indicated in the FAQ.

By itself you would need to add the Set statement for WSHNetwork.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top