newgentechnologies
asked on
Windows Script Host errors due to local device name in use already
One of my customers who is on a Windows 2003 Server based domain in their office, is the recieving the following error on login:
Windows Script Host
Script: \\WSM-SVR01-US\NETLOGON\lo gin.vbs
Line: 52
Char: 6
Error: The local device name is already in use.
Code: 80070055
Source: WSHNetwork.MapNetworkDrive
What i've done previously for this error, is that in their login script, i have added "net use x: /delete /yes" many times, where x is the drive letter of any network mapping that is listed in their company .vbs script, which maps network drives for the user logging in, depending on which AD group they are in.
So in process, they login, the logon.bat runs which clears out each network drive, and then at the end of the file it calls for the .vbs script that re-maps everything. We did it this way because I couldn't figure out a simple way to have the .vbs script to cleare all mappings, before it tried mapping (to avoid any errors, similar to the one I mentioend above).
The odd thing is that this whole process works for mostly every user, but the odd user still has the Windows Script Host error bugging them about "the local device name is already in use" error.
Any ideas? Any questions? I want to try to explain this the best I can so I can get it resolved once and for all.
Windows Script Host
Script: \\WSM-SVR01-US\NETLOGON\lo
Line: 52
Char: 6
Error: The local device name is already in use.
Code: 80070055
Source: WSHNetwork.MapNetworkDrive
What i've done previously for this error, is that in their login script, i have added "net use x: /delete /yes" many times, where x is the drive letter of any network mapping that is listed in their company .vbs script, which maps network drives for the user logging in, depending on which AD group they are in.
So in process, they login, the logon.bat runs which clears out each network drive, and then at the end of the file it calls for the .vbs script that re-maps everything. We did it this way because I couldn't figure out a simple way to have the .vbs script to cleare all mappings, before it tried mapping (to avoid any errors, similar to the one I mentioend above).
The odd thing is that this whole process works for mostly every user, but the odd user still has the Windows Script Host error bugging them about "the local device name is already in use" error.
Any ideas? Any questions? I want to try to explain this the best I can so I can get it resolved once and for all.
ASKER
Where would this go in my vbs script?
The script is pretty much as follows currently:
Dim WshNetwork ' Initialize Network
dim loginname ' variable to hold user login name
Dim wsh, objreg,objcontainer,objrem ote,objreg key,dnameo bj
dim logfile
dim fso,appendout,ofile
dim userobj
dim groupobj
dim oshell
Set UserObj = Nothing
Set GroupObj = Nothing
set wshnetwork = wscript.CreateObject("wscr ipt.networ k") 'create network object
loginname = wshnetwork.UserName 'capture User name at logon
Set wsh = WScript.CreateObject("WScr ipt.Shell" )
Set UserObj = GetObject("WinNT://worldse rve/" & loginname)
For Each GroupObj In UserObj.Groups
If GroupObj.Name = "Vietnam" Then.. etc etc
The script is pretty much as follows currently:
Dim WshNetwork ' Initialize Network
dim loginname ' variable to hold user login name
Dim wsh, objreg,objcontainer,objrem
dim logfile
dim fso,appendout,ofile
dim userobj
dim groupobj
dim oshell
Set UserObj = Nothing
Set GroupObj = Nothing
set wshnetwork = wscript.CreateObject("wscr
loginname = wshnetwork.UserName 'capture User name at logon
Set wsh = WScript.CreateObject("WScr
Set UserObj = GetObject("WinNT://worldse
For Each GroupObj In UserObj.Groups
If GroupObj.Name = "Vietnam" Then.. etc etc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There's no need to use a batch to call the VBS. VBS is capable of removing Network Mapped Drives.
Call this sub before doing your mapping in your VBS script. It should remove all connected Network Drives - which if I read you correctly when you said "easy way to have .vbs clear all mappings" - then this will be what you want. If you want to remove specific drives, then use the RemoveNetworkDrive and the Drive Name.
http://msdn2.microsoft.com/en-us/library/d16d7wbf.aspx
Just in My experience... VBS has had better luck in removing persistant network drives than Batch. Try running the script manually on the problem computer and see if it finishes without error.
Sub Remove_All_Drives()
bForce = "True"
bUpdateProfile = "True"
Set objNetwork = CreateObject("WScript.Netw
Set objCheckDrive = objNetwork.EnumNetworkDriv
For i = 0 To objCheckDrive.Count - 1 Step 2
objNetwork.removeNetworkDr
Next
End Sub