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

Engineer's Toolset v10Guy Recommends: SolarWinds Engineer’s Toolset v10

This Engineer’s Toolset v10 provides a comprehensive console of 50 utilities for troubleshooting computer problems.  Guy says it helps me monitor what’s occurring on the network, and each tool teaches me more about how the underlying system operates.

There are so many good gadgets; it’s like having free rein of a sweetshop.  Thankfully the utilities are displayed logically: monitoring, network discovery, diagnostic, and Cisco tools.  Try the SolarWinds Engineer’s Toolset now!

Download your fully functional trial copy of the Engineer’s Toolset v10

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
‘ Version 2.1 – May 30th 2010
‘ —————————————————-‘
‘ 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."


‘ End of Script

Solarwinds Free WMI MonitorGuy Recommends: WMI Monitor and It’s Free!

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.  Fortunately, SolarWinds have created the WMI Monitor so that you can examine these gems of performance information for free.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

Do you need additional help?

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

If you like this page then please share it with your friends