+ Post New Thread
Results 1 to 10 of 10
Scripts Thread, A bewildering logon/logoff VBscript error problem in Coding and Web Development; We are becoming more and more confused by this little problem: We have a logon script to map drives and ...
  1. #1
    mcheung0's Avatar
    Join Date
    Sep 2008
    Location
    York
    Posts
    24
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    12

    A bewildering logon/logoff VBscript error problem

    We are becoming more and more confused by this little problem:
    We have a logon script to map drives and logoff script to remove them.
    These are implemented by the user on Server 2003.
    On logon all users encounter the script error:
    "Local device name already in use"
    Code: 8007055
    Source: WSHNetwork.MapNetworkDrive

    The line and character references point to a "G:" drive.

    On logoff all users encounter the script error:
    "Network connection doesn't exist"
    Code: 800708CA
    Source: WSHNetwork.RemoveNetworkDrive

    Again the line and character references point to the "G:" drive.

    Therefore, users are unable to disconnect from the "G:" drive as it apparently does not exist (which is does as it is visible) but adversely are unable to connect at logon as it "already exists". Peculiar no?

    When executing the scripts locally on a computer they run correctly so could it be a server problem?

    Thanks
    Michael

  2. #2

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    Is the users home drive set to G, by any chance? because Windows will map and unmap that for you.
    Last edited by powdarrmonkey; 7th January 2009 at 04:36 PM. Reason: speeling

  3. #3

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,160
    Thank Post
    98
    Thanked 318 Times in 260 Posts
    Blog Entries
    4
    Rep Power
    111
    What's the actual code you're using?

  4. #4
    mcheung0's Avatar
    Join Date
    Sep 2008
    Location
    York
    Posts
    24
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    12

    Code

    Powdarrmonkey: no it's not the home folder - thanks anyway

    Jamesb: here is the logon script:

    Option Explicit
    Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3
    Dim strDriveLetter1, strDriveLetter2, strDriveLetter3
    dim strMessage
    dim WshNetwork
    Dim strUNCPrinter1, strUNCPrinter2, strUNCPrinter3

    strDriveLetter1 = "G:"
    strDriveLetter2 = "S:"
    strDriveLetter3 = "T:"
    strRemotePath1 = "\\hades\VCD Files"
    strRemotePath2 = "\\artemis\sims"
    strRemotePath3 = "\\prometheus\tregelles\shared teaching data"

    Set objNetwork = CreateObject("WScript.Network")

    ' Section which maps drives, G:, S:, & T:

    objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
    objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
    objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3

    __________________________________________________ __

    The error points to "objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1"



    here is the logoff script:

    Option Explicit

    ' Defines variables

    Dim objNetwork, strDriveLetter1, strDriveLetter2, strDriveLetter3
    Dim objWMIService
    Dim objPrinter
    Dim strComputer
    Dim strPrinter
    Dim colInstalledPrinters

    ' Inializes variables with drive letters

    strDriveLetter1 = "G:"
    strDriveLetter2 = "S:"
    strDriveLetter3 = "T:"

    Set objNetwork = CreateObject("WScript.Network")

    ' Section which removes strDriveLetter

    objNetwork.RemoveNetworkDrive strDriveLetter1
    objNetwork.RemoveNetworkDrive strDriveLetter2
    objNetwork.RemoveNetworkDrive strDriveLetter3
    ________________________________________

    The error points to "objNetwork.RemoveNetworkDrive strDriveLetter1"

    As I say, when running the scripts manually they run correctly

    Thanks
    Michael

  5. #5

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,160
    Thank Post
    98
    Thanked 318 Times in 260 Posts
    Blog Entries
    4
    Rep Power
    111
    Do the other two drives map successfully when running it from the server?

  6. #6
    mcheung0's Avatar
    Join Date
    Sep 2008
    Location
    York
    Posts
    24
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    12
    Yes they throw no errors

  7. #7

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,154
    Thank Post
    114
    Thanked 527 Times in 450 Posts
    Blog Entries
    2
    Rep Power
    123
    In the past, I've used functions like the ones below to handle drive mapping/unmapping. they make sure the drive letter is not in use before attempting to map and force a disconnect. the unmap checks to make sure the connection is there before trying to unmap.

    You can just call (eg)
    Code:
    MapNetworkDrive "G:", "\\server\share"
    when you want to map and
    Code:
    UnMapNetworkDrive "G:"
    when you want to unmap.

    Code:
    Sub MapNetworkDrive(sDrive,sShare)
      sDrive=ucase(sDrive)
      Set clDrives = oNetwork.EnumNetworkDrives
      For i = 0 to clDrives.Count -1 step 2
        if ucase(clDrives.Item(i))=sDrive then
          oNetwork.removenetworkdrive sDrive,true,true 'force and update profile
          exit for
        end if
      next
      oNetwork.mapnetworkdrive sDrive,sShare,false 'don't update profile
    end sub
    
    Sub UnMapNetworkDrive(sDrive)
      sDrive=ucase(sDrive)
      Set clDrives = oNetwork.EnumNetworkDrives
      For i = 0 to clDrives.Count -1 step 2
        if ucase(clDrives.Item(i))=sDrive then
          oNetwork.removenetworkdrive sDrive,true,true 'force and update profile
          exit for
        end if
      next
    end sub

  8. #8

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,160
    Thank Post
    98
    Thanked 318 Times in 260 Posts
    Blog Entries
    4
    Rep Power
    111
    Just out of curiousity, do the computers have card readers?

    What happens if you try changing the G: to a later drive letter, say N:?

  9. #9

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,758
    Thank Post
    825
    Thanked 1,662 Times in 1,447 Posts
    Blog Entries
    11
    Rep Power
    441
    Does the share still exist? What about security permissions?

  10. #10
    mcheung0's Avatar
    Join Date
    Sep 2008
    Location
    York
    Posts
    24
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    12

    Success!

    Thanks for all your responses - we're very grateful.
    In the end it was a simple solution - we had two sets of logon/logoff scripts.
    Therefore the first set mapped/removed all the drives correctly and then the second set attempted to map/remove once again causing the errors.

    The second set has been removed and now we are error free - hurrah!

    Michael

SHARE:
+ Post New Thread

Similar Threads

  1. VBScript Error
    By sqdge in forum Scripts
    Replies: 20
    Last Post: 13th September 2007, 03:34 PM
  2. Replies: 6
    Last Post: 3rd January 2007, 09:51 AM
  3. Replies: 3
    Last Post: 7th December 2006, 07:20 PM
  4. Replies: 0
    Last Post: 7th December 2006, 12:27 PM
  5. Replies: 0
    Last Post: 7th December 2006, 12:27 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •