Computer Performance, Windows 2003, Exchange 2003, Logon Scripts

Code  80020005 - Error: Type mismatch

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.Code 80020005  WSH Error: Type mismatch

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!

Tip for Code  80020005 - Error: Type mismatch 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()

DriveLetter = "N:" 'must be capitalized
RemotePath = "\\alan\home"
strRemoteName = "Guy"

WShNetwork.MapNetworkDrive DriveLetter, strRemoteName, RemotePath
WshShell.PopUp "Drive " & DriveLetter & " connected successfully."

 

Example 2 of Script with a Code 80020005 error

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")

strDriveLetter = "N:"
strHomeServer = "\\alan\home"
strProfile = "False" ' Mapping stored in user Profile
strUser = "Administrator"
strPassword = "pauline1"

objNetwork.MapNetworkDrive strDriveLetter, strHomeServer, strUser, strPassword
objPopUp.popup "Drive " & strDriveLetter & " connected successfully."

WScript.Quit

' End of Script

 

Solarwinds IpMonitorTry 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

Computer Training Software - Recommended Training VideosGuy Thomas recommends Computer Training Software

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.


Do you need extra help?

For interpreting the WSH messages check Diagnose 800 errors.

For general advice try my 7 Troubleshooting techniques

Give something back?

Would you like to help others?  If you have a good example of this error, then please email me, I will publish it with a credit to you:

What next? Try my eBook:


Download my Logon Script eBook for only $6.25

Logon ScriptThe 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.

  Jumbo Script 7 Package

See also

 *


Google

Webcomputerperformance.co.uk

GFi Events Manager

Guy Recommends: GFi EventsManager

Here is a solution to monitor, manage and archive thousands of events that are generated by devices across your entire network.  Get your free evaluation copy of GFI EventsManager.

 

Home Copyright © 1999-2008 Computer Performance LTD All rights reserved

Please report a broken link, or an error.