# Solved: VBScript: Map Network drive



## STAW (May 15, 2008)

Got another interesting problem. I'm working on a vbscript, one of the functions of which is to validate credentials a user has entered by attempting to map a drive with them. When I try to use the entered credentials, regardless of whether they're correct or not, I get the error "A device attached to the system is not functioning". If I comment out the end of the MapNetworkDrive command, removing the username and password, the drive maps correctly using current credentials. The code is below, the line causing the error in bold.



> strUser = arrArgs(1)
> strPassword = arrArgs(2)
> strLogFile = arrArgs(3)
> 
> ...


Any ideas?
I'd also be open to suggestions for a better was to validate these credentials, either with VBScript or C++ (the application is C++, but calls a series of VBScripts for various functions). Thanks.


----------



## STAW (May 15, 2008)

Found a better way of doing it. Totally scrapped the network drive idea in favor of this:



> wbemImpersonationLeveLImpersonate = 3
> wbemAuthenticationLevelPktPrivacy = 6
> 
> Set objLocator = CreateObject("WbemScripting.SWbemLocator")
> ...


Simple code, returns access denied if I specify an invalid password, even if the account I'm logged on to has the appropriate access, which is all I need it to do. The only problem I see is that you cannot specify credentials if hitting WMI and the local machine, so I need a remote machine to use, which can make futureprooifng difficult. Working on a few ideas for that portion, but it's not really relevant to this.


----------

