Announcement

Collapse
No announcement yet.

Ping Server - Map Multiple Drives in VB script

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

  • Ping Server - Map Multiple Drives in VB script

    I'd like to first ping the server and than map drive to each server's IP listed here, upon success delete the drive and move on. In case of no ping response or mapping error, it should send an email alert. My script works fine for pinging and emails upon error, but I need some help in Mapping area.

    ****************************************
    On Error Resume Next

    arrTargets = Array("192.168.1.20", _
    "192.168.1.21", _
    "192.168.1.22", _
    "192.168.1.23", _
    "192.168.1.24", _
    "192.168.1.25", _
    "192.168.1.26", _
    "192.168.1.27", _
    For Each strTarget In arrTargets
    Set objShell = CreateObject("WScript.Shell")
    Set objExec = objShell.Exec("ping -l 8 -n 3 -w 1000 " & strTarget)
    strPingResults = LCase(objExec.StdOut.ReadAll)
    If InStr(strPingResults, "reply from") Then
    ElseIf InStr(strPingResults, "negotiating") Then
    Else
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "[email protected]"
    objEmail.To = "[email protected]"
    etc etc etc etc etc etc
    ************************************

    Can anybody please show me how to Map C$ or IPC$ and delete it right after successful mapping for each server IP listed here?

    Thanks

  • #2
    Re: Ping Server - Map Multiple Drives in VB script

    Mapping a network drive is done via WScript.Network object.

    Some more example code is available in Guy Thomas' site, which contains a lot of scripting resouces and other stuff too.

    -vP

    Comment

    Working...
    X