Troubleshooting Code Error 80020005 - Type mismatch
Introduction to Code 80020005
This
error code, 80020005 usually occurs when you execute a VBScript.
Your logon script is
probably using a
method called MapNetworkDrive or SetDefaultPrinter.
The Symptoms you get
The script does not set the drive letter as you
would have hoped, instead you get a Windows Script Host error message. The probable scenario is that you are trying to create a Windows logon script.
The Cause of Code 80020005
What has happened here is there are too many arguments in your VBScript
method. The MapNetworkDriveMethod just needs a drive letter and a RemotePath.
In the example below the fault is that strRemoteName and RemotePath are:
a) Both pointing to the same network share b) Only one term is required, the other is superfluous so delete it!
Check the Source: To see which method is at fault. For example,
MapNetworkDrive or SetDefaultPrinter.
The Solution
Check the number of arguments required by the script method and compare with arguments
that you employed in your script. For example, change: WShNetwork.MapNetworkDrive DriveLetter, strRemoteName, RemotePath
To: - WShNetwork.MapNetworkDrive DriveLetter, RemotePath
Look for clues in the Line number, in this example note Line 9. Incidentally, Char:
1 is not helpful, this type of error just records the first character even
though the fault is further along the line.
Example 1 of Error 80020005
Too many arguments!
Line 9 should be: WShNetwork.MapNetworkDrive DriveLetter, RemotePath
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set AllDrives = WshNetwork.EnumNetworkDrives()
Rather than too many arguments, your script has too FEW arguments.
MapNetworkDrive can take up to 5 arguments. ' object.MapNetworkDrive 5
arguments: (strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword])
The strange situation is that if you use just the first two the script
works fine, however, if you want the 4th and 5th arguments, you must include
all 5. (Not just 1,2, 4,5)
In this script you need 5 arguments and only 4 are supplied.
Line 21 has the error: objNetwork.MapNetworkDrive strDriveLetter,
strHomeServer, strUser, strPassword
objNetwork.MapNetworkDrive strDriveLetter,
strHomeServer, strProfile, strUser, strPassword
This variable was declared but not used:
strProfile = "False" ' Mapping stored in user Profile
' TestConnect.vbs - Map Network Drive to N: to the alan server
' VBScript using all 5 MapNetworkDrive arguments.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.1 - May 30th 2004
' -----------------------------------------------------------------'
' object.MapNetworkDrive 5 arguments
' (strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword])
Option Explicit
Dim strUser, strPassword, strDriveLetter, strHomeServer, strProfile
Dim objNetwork, objPopUp
Set objNetwork = CreateObject("WScript.Network")
Set objPopUp = CreateObject("WScript.Shell")
Try
a different solution, download SolarWinds ipMonitor
Here is my thinking,
ipMonitor will give you valuable data about your network and servers.
This extra information just may unlock the solution to your error code.
One more thing, sometimes when troubleshooting you go around in circles;
therefore if you try a different, but related approach, you may just crack the
problem.
Free Download
of SolarWinds ipMonitor
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.
The extra features you get in your eBook
include, more pages full of detailed examples. Also, ten 'how to...'
sections, with screen shots showing which menus to use. Go for Guy's
eBook - and get a printable version with copy enabled and no expiry date.