Announcement

Collapse
No announcement yet.

VBScript On Error Resume

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

  • VBScript On Error Resume

    Hi All

    Just trying to tweak this script, it disconnects a network drive of X:, however I would like it to not give an error or exit if the drive isnt connected yet.

    this script is on logoff and just wanted to check i put the code in the right place

    ####################
    Option Explicit
    Dim objNetwork, strDriveLetter
    strDriveLetter = "X:"

    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.RemoveNetworkDrive strDriveLetter
    On Error Resume Next
    Wscript.Quit
    ####################

  • #2
    Re: VBScript On Error Resume

    Put your "On Error Resume Next" at the top of the script as it applies to all subsequent lines
    (Actually, moving it above objNetwork.Remove.... would work)
    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


    • #3
      Re: VBScript On Error Resume

      Thanks

      I will use this code

      #####################
      Option Explicit
      Dim objNetwork, strDriveLetter
      strDriveLetter = "X:"

      Set objNetwork = CreateObject("WScript.Network")
      On Error Resume Next

      objNetwork.RemoveNetworkDrive strDriveLetter
      Wscript.Quit

      #####################

      Comment

      Working...
      X