Solved

The specified network password is not correct error during script execution

Posted on 2007-11-16
5
2,432 Views
Last Modified: 2012-05-05
I am running the script attached and getting the error below
---------------------------
Windows Script Host
---------------------------
Script:      C:\Documents and Settings\user\Desktop\mappingdrives.vbs
Line:      32
Char:      13
Error:      The specified network password is not correct.

Code:      80070056
Source:       WSHNetwork.MapNetworkDrive

---------------------------
OK  
---------------------------

Line 32 in my script is objNetwork.MapNetworkDrive strDrive, strShare, True, True
'==============

Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")
 

Dim objNetwork

Set objNetwork = CreateObject("WScript.Network")
 

Dim objWinntUser

Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.UserName & ",user")
 

Dim strGroupToCheck, strGroupShare, strDrive, strShare
 

' Specity the group name, a semi-colon symbol, the drive letter, a semi-colon symbol, and the network share

arrGroupShares = Array( _

      "group1;Z;\\server\network\share1", _

      "group2;I;\\server\network\share2" _

      )
 

For Each strGroupShare In arrGroupShares

      strGroupToCheck = Split(strGroupShare, ";")(0)

      strDrive = Split(strGroupShare, ";")(1)

      If Right(strDrive, 1) <> ":" Then strDrive = strDrive & ":"

      strShare = Split(strGroupShare, ";")(2)

      If IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = True Then

            'MsgBox "You are a member of " & strGroupToCheck

            If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True, True

            objNetwork.MapNetworkDrive strDrive, strShare, True, True

      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = False Then

            'MsgBox "You are NOT a member of " & strGroupToCheck

      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = "Error" Then

            'MsgBox "There was no group found called " & strGroupToCheck

      End If      

Next
 

Function IsMemberOfGroup(strUserDomain, objUser, strGroup) 'the user is a member of a specified group

      IsMemberOfGroup = False

      Dim objGroup

      On Error Resume Next

      Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")

      If Err.Number Then

            IsMemberOfGroup = "Error"

      Else

            IsMemberOfGroup = objGroup.IsMember(objUser.ADsPath)

            'MsgBox objUser.ADsPath

      End If

End Function

'==============

Open in new window

0
Comment
Question by:vmamedov
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
Hi,

Try this......


regards
Chandru
Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")

 

Dim objNetwork

Set objNetwork = CreateObject("WScript.Network")

 

Dim objWinntUser

Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.UserName & ",user")

 

Dim strGroupToCheck, strGroupShare, strDrive, strShare

 

' Specity the group name, a semi-colon symbol, the drive letter, a semi-colon symbol, and the network share

arrGroupShares = Array( _

      "group1;Z;\\server\network\share1", _

      "group2;I;\\server\network\share2" _

      )

 

For Each strGroupShare In arrGroupShares

      strGroupToCheck = Split(strGroupShare, ";")(0)

      strDrive = Split(strGroupShare, ";")(1)

      If Right(strDrive, 1) <> ":" Then strDrive = strDrive & ":"

      strShare = Split(strGroupShare, ";")(2)

      If IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = True Then

            'MsgBox "You are a member of " & strGroupToCheck

            If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True

            objNetwork.MapNetworkDrive strDrive, strShare, True

      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = False Then

            'MsgBox "You are NOT a member of " & strGroupToCheck

      ElseIf IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = "Error" Then

            'MsgBox "There was no group found called " & strGroupToCheck

      End If      

Next

 

Function IsMemberOfGroup(strUserDomain, objUser, strGroup) 'the user is a member of a specified group

      IsMemberOfGroup = False

      Dim objGroup

      On Error Resume Next

      Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")

      If Err.Number Then

            IsMemberOfGroup = "Error"

      Else

            IsMemberOfGroup = objGroup.IsMember(objUser.ADsPath)

            'MsgBox objUser.ADsPath

      End If

End Function

'==============

Open in new window

0
 
LVL 12

Accepted Solution

by:
chandru_sol earned 500 total points
Comment Utility
Whoops!

Change this line

If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True

to

If objFSO.DriveExists(strDrive) = True Then objNetwork.RemoveNetworkDrive strDrive, True, True

regards
Chandru
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, I'm wondering if you've got some sort of cached credentials to a network resource....

Please follow the instructions in this article:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/usercpl_manage_passwords.mspx

to check if you have any cached passwords, and remove those that are for the same resource as the server you are trying to map a drive to.....

Regards,

Rob.
0
 

Author Comment

by:vmamedov
Comment Utility
thank you chandru/rob for all your help

chandru, your solution on a different post was it, it solved the problem
i have removed the 2nd true from adding network drives and it solved it, do i need to do the same for the removing of the drives???


rob, thank you for the original script and all the modifications that you have done

i will give full credit to chandru on this post and have already given full credit to rob on the other post that i have opened regarding the original script

again thanks for your help

if you both dont mind i have opened a another post regarding a different issue, if you can take a look at http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22970085.html
0
 

Author Closing Comment

by:vmamedov
Comment Utility
chandru was great and answered all my questions and his solution worked!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now