Script does not work

Home Forums Scripting General Scripting Script does not work

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    Mandrake
    Member
    #163927

    can any one look at this script I found and have been trying to get working on my server. I am not realy script sasy so I cant see any thing wrong with it but it still wont work. I just need someone who knows scripting enough to take a look at it I feel it is almost there but something keeps stuffing up.

    when running it I get the following error

    Line 79
    Char: 5
    Error: the network path was not found

    Code: 80070035
    Source: wshnetwork.mapnetworkdrive

    ‘Created by Richard Merz for mapping and renaming shares.
    ‘This will check to see if a drive is mapped and map if necessary. No action if already mapped.
    ’12April12

    ‘ ADD OR SUBTRACT AS MANY AS YOU WANT
    Option Explicit
    Dim objNetwork, strDrive, objShell, objUNC, objFSO
    Dim strRemotePath2, strDriveLetter2, strNewName2
    Dim strRemotePath3, strDriveLetter3, strNewName3
    Dim strRemotePath4, strDriveLetter4, strNewName4
    Dim strRemotePath5, strDriveLetter5, strNewName5
    Dim strRemotePath6, strDriveLetter6, strNewName6
    Dim strRemotePath7, strDriveLetter7, strNewName7
    Dim strRemotePath8, strDriveLetter8, strNewName8

    ‘ NEEDED FOR IF THEN
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objNetwork = CreateObject(“Wscript.Network”)

    ‘ DECLARING DRIVES AND UNC PATHS

    strDriveLetter2 = “M:”
    strRemotePath2 = “\\\\LCE-SERVER\\MYOB user”
    strNewName2 = “MYOB”
    ‘ Change the Letter, Path, and Name
    strDriveLetter3 = “O:”
    strRemotePath3 = “\\\\Fileserv\\data\\COMPANIES”
    strNewName3 = “Companies”
    ‘ Change the Letter, Path, and Name
    strDriveLetter4 = “J:”
    strRemotePath4 = “\\\\Fileserv\\data\\COMPANIES\\LCE Queensland\\Awarded Jobs”
    strNewName4 = “Awarded Jobs”
    ‘ Change the Letter, Path, and Name
    strDriveLetter5 = “x:”
    strRemotePath5 = “\\\\Fileserv\\data\\ESTIMATING”
    strNewName5 = “Estimating”
    ‘ Change the Letter, Path, and Name
    strDriveLetter6 = “R:”
    strRemotePath6 = “\\\\Fileserv\\data\\RESOURCES”
    strNewName6 = “Resources”
    ‘ Change the Letter, Path, and Name
    strDriveLetter7 = “S:”
    strRemotePath7 = “\\\\Fileserv\\data\\RESOURCES\\Scans”
    strNewName7 = “Scans”
    ‘ Change the Letter, Path, and Name
    strDriveLetter8 = “I:”
    strRemotePath8 = “\\\\Fileserv\\data\\IT”
    strNewName8 = “IT”
    ‘ Change the Letter, Path, and Name

    ‘ CHECKING TO SEE IF DRIVE IS MAPPED, IF IT IS IT IGNORES IT AND MOVES ON, IF IT IS NOT IT MAPS IT.

    ‘ Section to map the M network drive
    If (objFSO.DriveExists(“M:”) = True) Then
    objNetwork.RemoveNetworkDrive “M:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
    ‘ Section which actually (re)names the M Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2

    ‘ Section to map the O network drive
    If (objFSO.DriveExists(“O:”) = True) Then
    objNetwork.RemoveNetworkDrive “O:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3
    ‘ Section which actually (re)names the O Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3

    ‘ Section to map the J network drive
    If (objFSO.DriveExists(“J:”) = True) Then
    objNetwork.RemoveNetworkDrive “J:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4
    ‘ Section which actually (re)names the J Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter4).Self.Name = strNewName4

    ‘ Section to map the x network drive
    If (objFSO.DriveExists(“x:”) = True) Then
    objNetwork.RemoveNetworkDrive “x:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter5, strRemotePath5
    ‘ Section which actually (re)names the x Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter5).Self.Name = strNewName5

    ‘ Section to map the R network drive
    If (objFSO.DriveExists(“R:”) = True) Then
    objNetwork.RemoveNetworkDrive “R:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter6, strRemotePath6
    ‘ Section which actually (re)names the R Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter6).Self.Name = strNewName6

    ‘ Section to map the S network drive
    If (objFSO.DriveExists(“S:”) = True) Then
    objNetwork.RemoveNetworkDrive “S:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter7, strRemotePath7
    ‘ Section which actually (re)names the S Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter7).Self.Name = strNewName7

    ‘ Section to map the I network drive
    If (objFSO.DriveExists(“I:”) = True) Then
    objNetwork.RemoveNetworkDrive “I:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter8, strRemotePath8
    ‘ Section which actually (re)names the I Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter8).Self.Name = strNewName8

    WScript.Quit
    ‘ End of VBScript.[/CODE][CODE]

    ‘Created by Richard Merz for mapping and renaming shares.
    ‘This will check to see if a drive is mapped and map if necessary. No action if already mapped.
    ’12April12

    ‘ ADD OR SUBTRACT AS MANY AS YOU WANT
    Option Explicit
    Dim objNetwork, strDrive, objShell, objUNC, objFSO
    Dim strRemotePath2, strDriveLetter2, strNewName2
    Dim strRemotePath3, strDriveLetter3, strNewName3
    Dim strRemotePath4, strDriveLetter4, strNewName4
    Dim strRemotePath5, strDriveLetter5, strNewName5
    Dim strRemotePath6, strDriveLetter6, strNewName6
    Dim strRemotePath7, strDriveLetter7, strNewName7
    Dim strRemotePath8, strDriveLetter8, strNewName8

    ‘ NEEDED FOR IF THEN
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objNetwork = CreateObject(“Wscript.Network”)

    ‘ DECLARING DRIVES AND UNC PATHS

    strDriveLetter2 = “M:”
    strRemotePath2 = “\\\\LCE-SERVER\\MYOB user”
    strNewName2 = “MYOB”
    ‘ Change the Letter, Path, and Name
    strDriveLetter3 = “O:”
    strRemotePath3 = “\\\\Fileserv\\data\\COMPANIES”
    strNewName3 = “Companies”
    ‘ Change the Letter, Path, and Name
    strDriveLetter4 = “J:”
    strRemotePath4 = “\\\\Fileserv\\data\\COMPANIES\\LCE Queensland\\Awarded Jobs”
    strNewName4 = “Awarded Jobs”
    ‘ Change the Letter, Path, and Name
    strDriveLetter5 = “x:”
    strRemotePath5 = “\\\\Fileserv\\data\\ESTIMATING”
    strNewName5 = “Estimating”
    ‘ Change the Letter, Path, and Name
    strDriveLetter6 = “R:”
    strRemotePath6 = “\\\\Fileserv\\data\\RESOURCES”
    strNewName6 = “Resources”
    ‘ Change the Letter, Path, and Name
    strDriveLetter7 = “S:”
    strRemotePath7 = “\\\\Fileserv\\data\\RESOURCES\\Scans”
    strNewName7 = “Scans”
    ‘ Change the Letter, Path, and Name
    strDriveLetter8 = “I:”
    strRemotePath8 = “\\\\Fileserv\\data\\IT”
    strNewName8 = “IT”
    ‘ Change the Letter, Path, and Name

    ‘ CHECKING TO SEE IF DRIVE IS MAPPED, IF IT IS IT IGNORES IT AND MOVES ON, IF IT IS NOT IT MAPS IT.

    ‘ Section to map the M network drive
    If (objFSO.DriveExists(“M:”) = True) Then
    objNetwork.RemoveNetworkDrive “M:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
    ‘ Section which actually (re)names the M Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2

    ‘ Section to map the O network drive
    If (objFSO.DriveExists(“O:”) = True) Then
    objNetwork.RemoveNetworkDrive “O:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3
    ‘ Section which actually (re)names the O Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3

    ‘ Section to map the J network drive
    If (objFSO.DriveExists(“J:”) = True) Then
    objNetwork.RemoveNetworkDrive “J:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4
    ‘ Section which actually (re)names the J Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter4).Self.Name = strNewName4

    ‘ Section to map the x network drive
    If (objFSO.DriveExists(“x:”) = True) Then
    objNetwork.RemoveNetworkDrive “x:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter5, strRemotePath5
    ‘ Section which actually (re)names the x Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter5).Self.Name = strNewName5

    ‘ Section to map the R network drive
    If (objFSO.DriveExists(“R:”) = True) Then
    objNetwork.RemoveNetworkDrive “R:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter6, strRemotePath6
    ‘ Section which actually (re)names the R Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter6).Self.Name = strNewName6

    ‘ Section to map the S network drive
    If (objFSO.DriveExists(“S:”) = True) Then
    objNetwork.RemoveNetworkDrive “S:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter7, strRemotePath7
    ‘ Section which actually (re)names the S Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter7).Self.Name = strNewName7

    ‘ Section to map the I network drive
    If (objFSO.DriveExists(“I:”) = True) Then
    objNetwork.RemoveNetworkDrive “I:”, True, True
    End If
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.MapNetworkDrive strDriveLetter8, strRemotePath8
    ‘ Section which actually (re)names the I Mapped Drive
    Set objShell = CreateObject(“Shell.Application”)
    objShell.NameSpace(strDriveLetter8).Self.Name = strNewName8

    WScript.Quit
    ‘ End of VBScript.[/CODE]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.