Hi all,
Now first off I know as much about VB Scripting as I've learnt this morning. After the sucess I've had so far (up until this point) I'm really going to learn more about it.
Ok, so here's what I want to do. Upon user logon, the .vbs script will unmap all network drives on the client machine, remap them (this is to automate unmapping and mapping of new network shares in the future), then renames each of the drives.
Everything works up until the point of renaming the network drives. If I run the piece of code that renames the drives outside of this code it works so I'm guessing the mistake can only be minor.
Any suggestions grately received.
Option Explicit
Dim strDriveLetter1, strDriveLetter2, RemotePath1, RemotePath2
Dim objNetwork
Dim bForce, bUpdateProfile
Dim mDrive
bForce = "True"
bUpdateProfile = "True"
Set objNetwork = CreateObject("WScript.Network")
strDriveLetter1 = "F:"
strDriveLetter2 = "Y:"
RemotePath1 = "\\fpsl01\home"
RemotePath2 = "\\fpsl01\jbloggs"
' Removes all listed DriveLetters, with bForce, pUpdate Profile
On Error Resume Next
objNetwork.RemoveNetworkDrive strDriveLetter1, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter2, bforce, bUpdateProfile
' Maps the listed drives
objNetwork.MapNetworkDrive strDriveLetter1, RemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, RemotePath2
' Section which actually (re)names the Mapped Drives
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter1).Self.Name = "test1"
objShell.NameSpace(strDriveLetter2).Self.Name = "test2"
Wscript.Echo "Success - All done"
Wscript.Quit
Now first off I know as much about VB Scripting as I've learnt this morning. After the sucess I've had so far (up until this point) I'm really going to learn more about it.
Ok, so here's what I want to do. Upon user logon, the .vbs script will unmap all network drives on the client machine, remap them (this is to automate unmapping and mapping of new network shares in the future), then renames each of the drives.
Everything works up until the point of renaming the network drives. If I run the piece of code that renames the drives outside of this code it works so I'm guessing the mistake can only be minor.
Any suggestions grately received.
Option Explicit
Dim strDriveLetter1, strDriveLetter2, RemotePath1, RemotePath2
Dim objNetwork
Dim bForce, bUpdateProfile
Dim mDrive
bForce = "True"
bUpdateProfile = "True"
Set objNetwork = CreateObject("WScript.Network")
strDriveLetter1 = "F:"
strDriveLetter2 = "Y:"
RemotePath1 = "\\fpsl01\home"
RemotePath2 = "\\fpsl01\jbloggs"
' Removes all listed DriveLetters, with bForce, pUpdate Profile
On Error Resume Next
objNetwork.RemoveNetworkDrive strDriveLetter1, bforce, bUpdateProfile
objNetwork.RemoveNetworkDrive strDriveLetter2, bforce, bUpdateProfile
' Maps the listed drives
objNetwork.MapNetworkDrive strDriveLetter1, RemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, RemotePath2
' Section which actually (re)names the Mapped Drives
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter1).Self.Name = "test1"
objShell.NameSpace(strDriveLetter2).Self.Name = "test2"
Wscript.Echo "Success - All done"
Wscript.Quit