[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

The specified network password is not correct error during script execution

Posted on 2007-11-16
5
Medium Priority
?
2,561 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
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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

872 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