Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Graceful error handling...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jake  
View profile  
 More options Oct 21 2009, 8:13 am
Newsgroups: microsoft.public.scripting.vbscript
From: Jake <jak...@gmail.com>
Date: Wed, 21 Oct 2009 10:13:28 +0200
Local: Wed, Oct 21 2009 8:13 am
Subject: Graceful error handling...
Hi,

In my logon scripts I do some drive mappings.  Se code below.

However if there is an error in connecting to one of these drives, the
script throws an error and quits further executing.

How can I in vbs do a (pseudo code)

<if NOT nwo.MapNetworkDrive strDriveLetter, strPath" then
   ShowMessage("Error in mapping " & strDriveLetter & " to " & strPath)>

... and have the script continue execution on the next line?

What are the offending linenumber and charnumber variables in vbs if I
want to display these in the message box?

Thanks for help on this

regards

jake

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sub DeleteMapping(strDriveLetter)
'Remove former login's drive letters
'Give the PC time to do the disconnect, wait 300 milliseconds
  If fso.driveexists(strDriveLetter) Then
   nwo.RemoveNetworkDrive strDriveLetter, True, True
   wscript.sleep 300
  End If
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sub MapMyDrives(strDriveLetter, strPath, strDescription)
'Remove former login's drive letters
'Map drive to new letter...
'Set friendly name
  DeleteMapping strDriveLetter
  nwo.MapNetworkDrive strDriveLetter, strPath
  sao.NameSpace(strDriveLetter).Self.Name = strDescription
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MapMyDrives "R:", "\\172.23.1.10\Installations$", "Program Installers"
MapMyDrives "S:", "\\172.23.1.10\Info$", "Information folders"

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Oct 21 2009, 12:06 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Wed, 21 Oct 2009 05:06:06 -0700 (PDT)
Local: Wed, Oct 21 2009 12:06 pm
Subject: Re: Graceful error handling...
On Oct 21, 4:13 am, Jake <jak...@gmail.com> wrote:

VBS has only the 'On Error Resume Next' statement for such error
trapping.  The Err object can then deliver the error number and its
description, if there is one, but there is no way to programmatically
return the line number or character.  That information is just not
available to the script.  Therefore the best that could be done is
something like ...

function MapMyDrives(strDriveLetter, strPath, strDescription)
'Remove former login's drive letters
'Map drive to new letter...
'Set friendly name
  on error resume next
  DeleteMapping strDriveLetter
  if err.number <> 0 then
    ShowMessage(Err.description & " on " & strDriveLetter & " to " &
strPath)
    MapMyDrives = false
    exit sub
  end if
  nwo.MapNetworkDrive strDriveLetter, strPath
  if err.number <> 0 then
    ShowMessage(Err.description & " on " & strDriveLetter & " to " &
strPath)
    MapMyDrives = false
    exit sub
  end if
  sao.NameSpace(strDriveLetter).Self.Name = strDescription
  if err.number <> 0 then
    ShowMessage(Err.description & " on " & strDriveLetter & " to " &
strPath)
    MapMyDrives = false
    exit sub
  end if
  MapMyDrives = true
End function

I also changed the routine to a function that returns True if
successful and False for a failure for testingf in your main routine.
_____________________
Tom Lavedas


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google