Link to home
Start Free TrialLog in
Avatar of Splunker
Splunker

asked on

Getting a VB Script error: An Attempt was made to remember a device that had previously been remembered.

I am still getting error, Can anyone help me with this script. I seem to be so close.  I have been struggling with this for awhile. This is a startup script not a logon script.  I use a computer policy to start the script. Unless someone else has better script.  But I need to remove the map first if there is one then map it to where it needs to be. Reason why I need this, is I have tellers that sign onto there teller software at there branch and need map drive that points to that branches server. If I setup a Logon script all is fine, but the problem comes in when all my tellers move around from branch to branch their login script would be pointing at the wrong branch server. So I figured a Startup script would be better. I would create a computer policy that would be specific to each branch. All I would then have to do is put ther computer into that container with that policy. So no matter who signs onto that computer it will be mapped to the correct server. Please I need some help with this. Our Teller turn over rate is high so, I would rather not have to go setup map drive for each user profile on every machine. Hope this makes sense.

I have SP4 installed.

Line 31
Char 1
Error: An Attempt was made to remember a device that had previously been remembered.
Code: 800704B2
Source: wshNetwork.mapnetworkdrive

Here is the script code that I have running at startup.

**************************
Option Explicit


Dim objNetwork
Dim DriveLetter1, RemotePath1
Dim AllDrives, AlreadyConnected, Network1,i

Set Network1 = CreateObject("WScript.Network")
DriveLetter1 = "T:" ' This letter must be in CAPITALS.

RemotePath1 = "\\farnam-tlrsrvr\Teller"

Set objNetwork = CreateObject("WScript.Network")
Set AllDrives = objNetwork.EnumNetworkDrives()


AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2
If AllDrives.Item(i) = DriveLetter1 Then AlreadyConnected = True
Next

If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive DriveLetter1
objNetwork.MapNetworkDrive DriveLetter1, RemotePath1

Else

objNetwork.MapNetworkDrive DriveLetter1, RemotePath1

End if

WScript.Quit
' End of Script
Avatar of anil_u
anil_u

Change the following line
objNetwork.RemoveNetworkDrive DriveLetter1
to
objNetwork.RemoveNetworkDrive DriveLetter1, true, true
Avatar of Splunker

ASKER

Yeah, I found that suggestion also. I tried it earlier. I tried it again just to make sure. Still the same error.
ASKER CERTIFIED SOLUTION
Avatar of anil_u
anil_u

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Now I get error:

Line: 26
Char: 1
Error Unexpected 'Next'
Code: 800A041F
Source: Microsoft VBscript compilation error
Well I figured out the unexpected "next" error. But now I am back to the original error.  Heres how I fixed the last code.

Option Explicit


Dim objNetwork, WshShell
Dim DriveLetter1, RemotePath1, Command
Dim AllDrives, AlreadyConnected, Network1,i

Set Network1 = CreateObject("WScript.Network")
DriveLetter1 = "T:" ' This letter must be in CAPITALS.

RemotePath1 = "\\farnam-tlrsrvr\Teller"

Set objNetwork = CreateObject("WScript.Network")
Set AllDrives = objNetwork.EnumNetworkDrives()


AlreadyConnected = False
For i = 0 To AllDrives.Count - 1 Step 2

If AllDrives.Item(i) = DriveLetter1 Then
  Set WshShell = WScript.CreateObject("WScript.Shell")
  Command = "net use " & DriveLetter1 & " /delete /yes"
  WshShell.Run(Command), 7, True
  Set WshShell = nothing

END IF

NEXT  

objNetwork.MapNetworkDrive DriveLetter1, RemotePath1

WScript.Quit
' End of Script
Sorry bout that I did not test it.
Ok, the next thing to try would be to see if the "IF" statement is working

After the following line
For i = 0 To AllDrives.Count - 1 Step 2
type
wscript.echo  AllDrives.Item(i)

This will then output the drive letters
You would have to run this from the command prompt
start->run->cmd-> cd to script folder->cscript nameOfScript.vbs

If you do not see the T drive, change the IF statement to
For i = 0 To AllDrives.Count - 1


I am wondering now if its OS related. I have windows 2000 on my machine... the one I am testing with and I am getting these errors. I put another computer with XP into the same container with the group policy to run this script and it worked fine. No errors. Worked with my original script and the new one that you came up with. I am wondering whats up with my machine.