Discussion:
logon script for mapping
(too old to reply)
Bonno Bloksma
2009-11-27 15:10:42 UTC
Permalink
Hi,

Q Why does Windows XP refer to the old location as the X: drive when the logon script uses the new
location


This week transfered a directory form server A to server B. Changed the login scrip (domain policy,
user logion script) to reflect the new location.
Did not delete the old location completely as part of the files on that share are still in use.

The script part I use is quite simple:

----------<quote>---------------------------------
' MapX.vbs - Windows Logon Script
[....]
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set objADSysInfo = CreateObject("ADSystemInfo")

' Select is case sensitive in de tag
Select Case objADSysInfo.SiteName
[...]
Case "Rotterdam"
WSHNetwork.MapNetworkDrive "X:", "\\TioRtm2k8.staf.tio.nl\Applicaties"
Case Else
WScript.Echo "Site naam: " & objADSysInfo.SiteName & " is ONBEKEND"
End Select

----------<quote>---------------------------------

PCs have been logging off and on, been shut down an started but many still refer to the old location
as being the X: drive. The Map line used to be:
WSHNetwork.MapNetworkDrive "X:", "\\TioRtm2k3.staf.tio.nl\Applicaties"

Software on those PCs is now claiming it cannot find the files on X:\Dir\Dir\.... The sollution
seems to be to have the use disconnect the old X: drive, log off and then log on.
Funny thing is, this does not happen to all users, does not happen on alle PCs

This is the second time this has happend to these users. The first time I thought I had done
something wrong in the logon script and made the mapping a permanent mapping by mistake. The first
script was a site policy script which I later modified into a user script that determined the site.
After that change many/all users got errors executing the news script claiming there was a X: drive
which could not be changed by the script.

However, this time I am 100% sure of the previous mapping line in the script and it is NOT telling
Windows XP to make it a permanent mapping. So why does Windows XP keer refering to the old location
as the X: drive?

Bonno Bloksma
Richard Mueller [MVP]
2009-11-27 18:18:30 UTC
Permalink
Post by Bonno Bloksma
Hi,
Q Why does Windows XP refer to the old location as the X: drive when the
logon script uses the new location
This week transfered a directory form server A to server B. Changed the
login scrip (domain policy, user logion script) to reflect the new
location.
Did not delete the old location completely as part of the files on that
share are still in use.
----------<quote>---------------------------------
' MapX.vbs - Windows Logon Script
[....]
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set objADSysInfo = CreateObject("ADSystemInfo")
' Select is case sensitive in de tag
Select Case objADSysInfo.SiteName
[...]
Case "Rotterdam"
WSHNetwork.MapNetworkDrive "X:", "\\TioRtm2k8.staf.tio.nl\Applicaties"
Case Else
WScript.Echo "Site naam: " & objADSysInfo.SiteName & " is ONBEKEND"
End Select
----------<quote>---------------------------------
PCs have been logging off and on, been shut down an started but many still
WSHNetwork.MapNetworkDrive "X:", "\\TioRtm2k3.staf.tio.nl\Applicaties"
Software on those PCs is now claiming it cannot find the files on
X:\Dir\Dir\.... The sollution seems to be to have the use disconnect the
old X: drive, log off and then log on.
Funny thing is, this does not happen to all users, does not happen on alle PCs
This is the second time this has happend to these users. The first time I
thought I had done something wrong in the logon script and made the
mapping a permanent mapping by mistake. The first script was a site policy
script which I later modified into a user script that determined the site.
After that change many/all users got errors executing the news script
claiming there was a X: drive which could not be changed by the script.
However, this time I am 100% sure of the previous mapping line in the
script and it is NOT telling Windows XP to make it a permanent mapping. So
why does Windows XP keer refering to the old location as the X: drive?
Bonno Bloksma
Perhaps the problem is persistent connections. If you use "On Error Resume
Next" in your logon scripts you may not be alerted that the mapping raises
an error. I would suggest trapping the possible error, then attempt to
remove any existing mapping, then try again. For example:

Case "Rotterdam"
' Trap error if mapping fails.
On Error Resume Next
WSHNetwork.MapNetworkDrive "X:", "\\TioRtm2k8.staf.tio.nl\Applicaties"
If (Err.Number <> 0) Then
' Restore normal error handling.
On Error GoTo 0
' Remove any existing drive mapping (persistent).
' Remove even if the mapping is in use and remove persistence.
WSHNetwork.RemoveNetworkDrive, "X:", True, True
' Second attempt to map drive. Trap and report any error.
On Error Resume Next
WSHNetwork.MapNetworkDrive "X:",
"\\TioRtm2k8.staf.tio.nl\Applicaties"
If (Err.Number <> 0) Then
' Report error.
Call MsgBox("Unable to map drive X:" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Description: " & Err.Description, _
vbOKOnly + vbCritical, "Logon Script")
End If
End If
' Restore normal error handling.
On Error GoTo 0
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Loading...