|
Guy recommends :
Find out which of your VMs are a waste of space and which VMs need more resources. |
Windows Logon Scripts - MapNetworkDrive Error Correcting CodeIntroduction to Map Network Drive - Error Correcting CodeOnce your MapNetworkDrive script is working, you may wish to add error correcting code. This page shows you strategies, tactics and methods to handle Microsoft VBScript problems, for example, the logon script fails because the servername is misspelt. Topics for MapNetworkDrive Error Correcting CodeError Correcting Code StrategiesYour first decision is whether to simply ignore the script problem, whether it would be better to fix it. By ignoring the problem I mean that you could just add On Error Resume Next. Assuming you want to handle the problem you need to trap the WSH code number with err.number. Error Number - Err.NumberError number background.Each Microsoft VBScript error has a number. What is confusing in troubleshooting is that sometimes the number is represented in hex, while on other occasions you see it in decimal. The WSH Code Error message boxes display in hex with a number beginning 800xxxxx. However, the err.number command will display the same error buy translated into decimal. ̃ Windows Scripting Host - Message Box
In the example opposite, Source WSHNetwork.MapNetworkDrive confirms the object and method that are causing the error. Finally, the code hex number : 8000704CF, while having no meaning itself is invaluable in looking up similar errors in Google. My idea would be to research, and discover other people who have experienced the error and look for similarities between their cause and yours. The line with Error: 'The network location cannot be reached....' yields more valuable information. What this means is that VBScript cannot find the server. What Can you Do? The burning question is what can you do about these error numbers? How will you handle them. To answer that question you need a mixture of pure scripting techniques, mixed with a little logic. Take as an example, the drive letter is already mapped, what would like the script to do? a) Remove the mapped drive and map a different share. b) Ignore mapping that drive letter, and proceed with the rest of the script. A quick refresher of extra scripting terms needed for error handling. Err.number - Each time WSH encounters an error, it displays a message box and code number and other useful details. Err is a valid VBScript object on a par with objNetwork. .number is its property, and the .number value is decimal not hex. vbEmpty - Visual Basic empty, another way of saying zero. Once you get used to the term, vbEmpty is clearer than a 0, which could be a zero or the letter 'oh'. If .. then else. endif - This old faithful introduces branching and matches real life logic with scripting logic. If the drive is already mapped, then disconnect it. Select Case - Expands the If...then, and especially the else. If you add more than 3 elseif statements the script gets messa, Select Case is an eloquent solution. sub GuyCase() - Sub routine to call Select Case. I find you get more information if you call a subroutine after each drive mapping, otherwise you may miss a second or third error. RemoveNetworkDrive - The opposite of MapNetworkDrive. A simple, easy to use VBScript command, common in logon scripts. EnumNetworkDrives - Needed to count or enumerate the drives that already present. My view is EnumNetworkDrives gives us a handle so we can manipulate drives, for example disconnect them. WScript.Quit
Guy
Recommends: Permissions Analyzer - Free Active Directory Tool
|
||||
Custom Search
|
Guy Recommends: WMI Monitor and It's Free!
|
|
Author: Guy Thomas Copyright © 1999-2012 Computer Performance LTD All rights reserved. Please report a broken link, or an error to: | |