Gongalong Posted November 12, 2013 Posted November 12, 2013 Hi folks, I've got a drive mapping via script issue... On my PC there are 4 scripts that run to map drives. These are legacy scripts from when I started working here, and are linked with GPOs. One is specific to IT support, and the others are standards scripts that are running on other staff PCs without issue. I don't think this happened immediately when I switched to Windows 8, so perhaps it was when upgrading to 8.1, but now two of the scripts fail with a "The local device name is already in use" error. I've done the usual, and checked the drives aren't already mapped, and that they aren't assigned to other devices. Neither seem to be the case. When I check the drive listings, disconnect the problem drive letters, and run the scripts again, they run without issue (!). For reference purposes the first script maps F, G, H, I, L, M, P, and R. It fails at P. The second script maps T, V, W, Y, and Z. It fails at T. Any ideas on what might be causing this? TIA
PotNoodleTech Posted November 12, 2013 Posted November 12, 2013 (edited) As you're having trouble with your existing scripts - now may be a good time to move to drive mapping via GPO? It's really easy and so far here 100% reliable. Have not needed to use log in scripts for ages (except the odd occasion when I want to copy a file or something, but even that can be done with GPO nowadays!). GPMC > User Configuration > Preferences > Windows Settings > Drive Maps Add each of your drive maps as "replace" and then get rid of your login script's from the users. You can also Hide drives if you need to e.g I've got my SIMS and public apps drives hidden. That's my 2p anyway! Edited November 12, 2013 by PotNoodleTech 1
Duke5A Posted November 12, 2013 Posted November 12, 2013 Is your script written in VB? I had something similar to this happen a couple years ago and wound up adding a couple lines to the script to disconnect drives if it detected they were already in use. Another thing I could possibly think of is the drive letter is in use by a card reader or sort and it's hidden in Explorer since there is no media in it. 1
Gongalong Posted November 13, 2013 Author Posted November 13, 2013 AButters: yep, I'd like to. There's just not been a convenient time to trial it. Duke5A: yes, they're in VB. The script sets a bunch of values i.e. the drive letter, the path, and the assigned name. It then uses a CreateObject("WScript.Network") with a CreateObject("Shell.Application") to map and name the drives. I found after all that for one of the scripts the drive *had* been mapped, hence the conflict. But not for the second script, which maps T, V, W, Y, and Z, and fails at T. Oddly the scripts take 5 or so minutes before they actually execute, so I sat watching Windows Explorer this morning to see if it gave any clues as to what was going on, but bizarrely T mapped without error. If it comes back I'll revist.
mac_shinobi Posted November 13, 2013 Posted November 13, 2013 Could do with posting both scripts - also how come they are separate scripts, why not put them into one script ? Just out of curiosity ? 1
Gongalong Posted November 13, 2013 Author Posted November 13, 2013 The scripts are GPO dependent i.e. it depends who you are as to what you get. Script as follows. I've taken out the share paths and names (not that I'm paranoid...): Option Explicit Dim objNetwork, strDrive, objShell, objUNC Dim strRemotePath1, strRemotePath2, strRemotePath3, strRemotePath4, strRemotePath5 Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strDriveLetter4, strDriveLetter5 Dim strNewName1, strNewName2, strNewName3, strNewName4, strNewName5 ' strDriveLetter1 = "T:" strDriveLetter2 = "V:" strDriveLetter3 = "W:" strDriveLetter4 = "Y:" strDriveLetter5 = "Z:" strRemotePath1 = "UNC Share Path" strRemotePath2 = "UNC Share Path" strRemotePath3 = "UNC Share Path" strRemotePath4 = "UNC Share Path" strRemotePath5 = "UNC Share Path" strNewName1 = "Share Name" strNewName2 = "Share Name" strNewName3 = "Share Name" strNewName4 = "Share Name" strNewName5 = "Share Name" ' Section to map the network drives Set objNetwork = CreateObject("WScript.Network") objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1 objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2 objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3 objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4 objNetwork.MapNetworkDrive strDriveLetter5, strRemotePath5 ' Section which actually (re)names the Mapped Drive Set objShell = CreateObject("Shell.Application") objShell.NameSpace(strDriveLetter1).Self.Name = strNewName1 objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2 objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3 objShell.NameSpace(strDriveLetter4).Self.Name = strNewName4 objShell.NameSpace(strDriveLetter5).Self.Name = strNewName5 ' End of script.
sted Posted November 13, 2013 Posted November 13, 2013 when I used vbs for drive maps I used to use this which removes them first 'drive-print.vbs Jonathan 19-09-08 Option Explicit Dim objNetwork, objShell Set objNetwork = CreateObject("WScript.Network") On Error Resume Next 'map user drives objNetwork.RemoveNetworkDrive "U:" objNetwork.RemoveNetworkDrive "R:" objNetwork.RemoveNetworkDrive "V:" objNetwork.MapNetworkDrive "U:", "\\server\users$\staff\" & objNetwork.UserName objNetwork.MapNetworkDrive "R:", "\\server\Resources$" objNetwork.MapNetworkDrive "V:", "\\server\users$" 'map printers Set objNetwork = CreateObject("WScript.Network") objNetwork.AddWindowsPrinterConnection "\\server\colour1" objNetwork.AddWindowsPrinterConnection "\\server\laser1" 'objNetwork.AddWindowsPrinterConnection "\\server\cedar" objNetwork.SetDefaultPrinter "\\server\Laser1" 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now