Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Map Network Drive Password Error? 1

Status
Not open for further replies.

dfnkt

IS-IT--Management
Dec 4, 2007
12
US
Hello all, thank you for your time.

We are going to transfer our logon/logoff scripts from batch files to vbscript files. I have written a simple logon script for one of the departments that looks like this.

'===================
'cpsupport.vbs
'12/04/2007
'author: caley woods
'===================
Option Explicit
'==============================
'Declaring variables to be used
'==============================
Dim objNetwork, strDriveLetter1, strDriveLetter2, strDriveLetter3, strDriveLetter4, strProfile
Dim strRemotePath1, strRemotePath2, strRemotePath3, strRemotePath4, strUserName, strPassword
Set objNetwork = CreateObject("WScript.Network")
'========================================
'Defining the Drive Letters and UNC Paths
'========================================
strDriveLetter1 = "R:" 'Must be Capital
'strDriveLetter2 = "Y:"
'strDriveLetter3 = "T:"
'strDriveLetter4 = "W:"
strRemotePath1 = "\\server.domain.int\computersup" 'UNC name
'strRemotePath2 = "\\server.domain.int\v000"
'strRemotePath3 = "\\server2.domain.int\v214"
'strRemotePath4 = "\\server2.domain.int\V095"
strUserName = "user"
strPassword = "password"
strProfile = "False"
'======================================
'Mapping the UNC Path to a Drive Letter
'======================================
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, strProfile, strUserName, strPassword
'objWSHNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2, strProfile, strUserName, strPassword
'objWSHNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3, strProfile, strUserName, strPassword
'objWSHNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4, strProfile, strUserName, strPassword
Wscript.Echo "Successfully Mapped Drives"
Wscript.Echo "Cleaning variables out of memory"
'======================================================
'Below cleans up used memory from the Dim command above
'======================================================
set objNetwork = nothing
set strDriveLetter1 = nothing
set strDriveLetter2 = nothing
set strDriveLetter3 = nothing
set strDriveLetter4 = nothing
set strRemotePath1 = nothing
set strRemotePath2 = nothing
set strRemotePath3 = nothing
set strRemotePath4 = nothing
set strUserName = nothing
set strPassword = nothing
Wscript.Quit

The script isnt final, in the final version the Wscript.Echo messages will be removed so the script is silent. You will notice a bunch of things commented out, this is currently for troubleshooting purposes. And all of the variables or strings that appear on another line really are not.

My question is, I receive "The specified network password is not correct." when I run the script. I am baffled by what is causing this, my only guess is that it has something to do with how the script is supplying the username and password to the server and not a bad password in my script. I can successfully open a command line and do 'net use R: \\server.domain.int\share' and then type in the username and password just as I have it in my script and it works no problem, what am I missing? Thank you again, sorry for the long post.
 
looks like you are using a generic domain account to map all drives in this script instead of the actual user accounts of the people logging in. i think if you change:

strUserName = "user"

to:
strUserName = "domain\user"

It will probably work. If you want a better way to do this read this:


RoadKi11

RoadKi11

"This apparent fear reaction is typical, rather than try to solve technical problems technically, policy solutions are often chosen." - Fred Cohen
 
It works perfectly now, thank you and I will look into the VBScript FAQ.
 
Ouch, that is one ugly script. Why do you bother to declare variables for the drive letters and not just use the drive letter in the MapNetworkDrive command?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
markdmac: to be quite honest, I have just started with VBScript and as of a week ago, I knew nothing about it. I guess you could consider this my 'first' script.

This will be improved upon as I learn, and in the end I hope to be able to just have one single or maybe even 2-3 if need be, logon scripts versus the 101 batch files that are currently stored for use by different departments. In order to get them all into the single file (multiple if need be) I want to write a script to query AD and determine if they are part of X group then map Y drives.
 
Use the script in my FAQ referenced above. It has all the functionality you are looking for.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top