[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

The specified network password is not correct error during script execution

Posted on 2007-11-16
5
Medium Priority
?
2,542 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20303168
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 2000 total points
ID: 20303175
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
ID: 20308788
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
ID: 20312432
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
ID: 31409619
chandru was great and answered all my questions and his solution worked!!!
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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