Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > logon script for mapping

Reply
Thread Tools Display Modes

logon script for mapping

 
 
Bonno Bloksma
Guest
Posts: n/a

 
      11-27-2009
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


 
Reply With Quote
 
 
 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      11-27-2009

"Bonno Bloksma" <> wrote in message
news:4b0febf3$0$22945$...
> 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
>
>


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
--


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SBS Logon Script Bill Windows Small Business Server 8 11-16-2009 06:13 PM
GP Logon Script works first time at second user logon Roland Schoen Active Directory 2 11-09-2009 12:19 PM
Detect Vista in Logon Script Dave Windows Vista Administration 11 05-25-2008 06:01 PM
User Accounts can't be set to Administrator Steve A. Windows Vista Administration 10 03-09-2008 06:35 AM
Unable to run vbs logon script Wajinga Windows Vista Administration 1 06-13-2006 09:01 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59