1. Welcome Guest! In order to create a new topic or reply to an existing one, you must register first. It is easy and free. Click here to sign up now!.
    Dismiss Notice

VB Script for Mapping Network Folders

Discussion in 'Windows Home Server' started by circulent, Aug 24, 2009.

  1. circulent

    circulent Guest

    I'm running a Win2008 domain, and have a User-based GPO referencing a VB
    script which shares several network folders, each shared from a single file
    server. This GPO applies to "Domain Users." What's odd is that I get an error
    when logging into the file server itself as Administrator. Here is the script
    and the error:

    Script:

    ' VBScript logon script program.
    Option Explicit
    Dim objNetwork

    Set objNetwork = CreateObject("Wscript.Network")

    ' Trap error if R: already in use.
    On Error Resume Next
    objNetwork.MapNetworkDrive "R:", "\\SQL1\marketing"
    If (Err.Number <> 0) Then
    ' Restore normal error handling.
    On Error GoTo 0
    ' Attempt to remove drive mapping.
    objNetwork.RemoveNetworkDrive "R:", True, True
    ' Try again to map the drive.
    objNetwork.MapNetworkDrive "R:", "\\SQL1\marketing"
    End If
    ' Restore normal error handling.
    On Error GoTo 0

    Error:

    Script: \\domain.local\...\share.vbs
    Line: 14
    Char: 5
    Error: This network connection does not exist
    Code: 800708CA
    Source: WSHNetwork.RemoveNetworkDrive

    Thoughts?
     
  2. Tim Munro

    Tim Munro Guest

    From what I'm seeing here you are trying to map a network drive with a local
    account without providing any credentials. This won't work. If I counted
    properly your error is coming from the the "RemoveNetworkDrive" command. The
    drive R: doesn't exist (and probably never will in this scenario).

    Your error checking on the MapNetworkDrive command just checks to see if an
    error occurred, not WHAT error occurred.

    --
    Tim

    "circulent" <circulent@discussions.microsoft.com> wrote in message
    news:73922BA0-D6AF-4B6C-9824-E058E9C21B4E@microsoft.com...<!--coloro:blue--><span style="color:blue <!--/coloro-->
    > I'm running a Win2008 domain, and have a User-based GPO referencing a VB
    > script which shares several network folders, each shared from a single
    > file
    > server. This GPO applies to "Domain Users." What's odd is that I get an
    > error
    > when logging into the file server itself as Administrator. Here is the
    > script
    > and the error:
    >
    > Script:
    >
    > ' VBScript logon script program.
    > Option Explicit
    > Dim objNetwork
    >
    > Set objNetwork = CreateObject("Wscript.Network")
    >
    > ' Trap error if R: already in use.
    > On Error Resume Next
    > objNetwork.MapNetworkDrive "R:", "\SQL1marketing"
    > If (Err.Number <> 0) Then
    > ' Restore normal error handling.
    > On Error GoTo 0
    > ' Attempt to remove drive mapping.
    > objNetwork.RemoveNetworkDrive "R:", True, True
    > ' Try again to map the drive.
    > objNetwork.MapNetworkDrive "R:", "\SQL1marketing"
    > End If
    > ' Restore normal error handling.
    > On Error GoTo 0
    >
    > Error:
    >
    > Script: \domain.local...share.vbs
    > Line: 14
    > Char: 5
    > Error: This network connection does not exist
    > Code: 800708CA
    > Source: WSHNetwork.RemoveNetworkDrive
    >
    > Thoughts? <!--colorc--><!--/colorc-->
     

Share This Page