Re: List and remap shares
- From: Gary Mort <gmms@xxxxxxxxxxx>
- Date: Tue, 11 Oct 2005 12:28:16 -0400
Daniel wrote:
Check this article, I think it addresses your issue
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0928.mspx
Hope this help,
Daniel
Thanks, that did it. I was able to hack this little guy together. I don't quite have the hang of VBS, so if the user doesn't enter a userid or password, while the program complains it doesn't abort.
For anyone curious, I've discovered that while windowes will prevent you from connecting to file shares on a server with different userids, it only cares about what you call the server not the actual address. So you can end up with one userid for \\servername\shareone and a different userid for \\servername.my.domain\sharetwo
What is really fun is when you have a clueless user who has been setup by fellow helpful users with different philosophies. So one person maps him to a drive with \\server.my.domain\share and his ID and another maps him to \\127.0.0.1\sharetwo (the IP address of the server) because he doesn't trust the DNS servers.
The user is using the same userid for both shares, and then changes his password some months later(non-integrated network) and corrects it on one shaename. Meanwhile the computer will happily keep trying to reconnect him on bootup to the other share and failing. If he has enough of these shares, he can get himself locked out after too many failures.
Thus I needed a utility to get all the different sharenames and map them all to one std.
---remap.vbs---- Const ServerNAME = "\\servername\" Const ServerFQDN = "\\servername.my.domain\" Const ServerIP = "\\127.0.0.1\"
Dim mapnewDrives()
numDrives = 0
newuserid = InputBox("Please enter your userid for " & ServerFQDN & ":")
If newuserid = "" Then
Wscript.Echo "No userid entered"
End If
newpassword = InputBox("Please enter your password for " & ServerFQDN & ":")
If newpassword = "" Then
Wscript.Echo "No userid entered"
End If
Set objNetwork = CreateObject("Wscript.Network")Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
shareData = colDrives.item(i+1)
pos = InStrRev(shareData, "\")
shareName = Mid(shareData,pos+1)
InAny = 0
InAny = InStr(1, shareData, ServerNAME, vbTextCompare) + InStr(1, shareData, ServerFQDN, vbTextCompare) + InStr(1, shareData, ServerIP, vbTextCompare)
wscript.echo shareData
wscript.echo InAny
If InAny > 0 Then
strDriveLetter = colDrives.Item(i)
numDrives = numDrives + 2
Redim Preserve mapnewDrives(numDrives)
mapnewDrives(numDrives - 2) = StrDriveLetter
mapnewDrives(numDrives - 1) = ServerFQDN & shareName
objNetwork.RemoveNetworkDrive strDriveLetter, True, True
End If
Next
For i = 0 to (numDrives -1) Step 2
objNetwork.MapNetworkDrive mapnewDrives(i), mapnewDrives(i+1), true, newuserid, newpassword
Next
---remap.vbs----
.
- References:
- List and remap shares
- From: Gary Mort
- List and remap shares
- Prev by Date: Re: Writing and debugging VBS
- Next by Date: Create printers on Windows Storager Server 2003??
- Previous by thread: List and remap shares
- Next by thread: Error Handling...
- Index(es):
Relevant Pages
|