Announcement

Collapse
No announcement yet.

VB Script To Map Drive

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VB Script To Map Drive

    I am trying to create a script to map a network drive then open a folder displaying the contents of the newly mapped drive. This is the script I have (I am a newbie) but it does not open...it generates the error 'Untermminated string constant' code: 800A0409
    Code:
    Dim shell
    Dim objNetwork
    Set objNetwork = WScript.CreateObject("WScript.Network")
    strLocalDrive = "L:"
    strRemoteShare = "194.32.68.123\data"
    strPer = "FALSE"
    strUsr = "DiggityDogDomain\craymond"
    strPas = "password"
    objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer, strUsr, strpas
    Set shell = wscript.CreateObject("ShellApplication)
    shell.Open "\\194.32.68.123\data\"
    Last edited by jo15765; 18th October 2014, 01:44.

  • #2
    Re: VB Script To Map Drive

    After a little more googling and a little more trial and error I finally got my script working as expected.
    Code:
    Dim objNetwork, strLocalDrive, strRemoteShare, strPer, strUsr, strPas, shell
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objNetwork = CreateObject("WScript.Network")
    If (objFSO.DriveExists("L:")=True) Then
    	objNetwork.RemoveNetworkDrive "L:", True, True
    End If
    Set objNetwork = WScript.CreateObject("WScript.Network")
    strLocalDrive = "L:"
    strRemoteShare = "194.32.68.123\data"
    strPer = "FALSE"
    strUsr = "DiggityDogDomain\craymond"
    strPas = "password"
    objNetwork.MapNetworkDrive strLocalDrive, strRemoteShare, strPer, strUsr, strpas
    Set shell = wscript.CreateObject("ShellApplication)
    shell.Open "\\194.32.68.123\data\"

    Comment


    • #3
      Re: VB Script To Map Drive

      Well done, and thanks for posting back with the solution
      Tom Jones
      MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
      PhD, MSc, FIAP, MIITT
      IT Trainer / Consultant
      Ossian Ltd
      Scotland

      ** Remember to give credit where credit is due and leave reputation points where appropriate **

      Comment

      Working...
      X