Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Ping Server - Map Multiple Drives in VB script

  • 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("", _
    "", _
    "", _
    "", _
    "", _
    "", _
    "", _
    "", _
    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
    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?


  • #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.