Access this solution immediately by signing up as a member of VBScriptExperts.com--it’s quick, easy, and secure. We will return you to this solution, unlocked, when you’re done.
Hello..
A few years ago I put a simple hta together to help our users map network drives when they were using the vpn from home. The hta was fairly simple
- it would ask for the username/password and
-try to map a drive and error trap the results..
-if everything worked it would map a number of other drives from the same resource {same host /different shares}
This worked well for several years but now users are reporting problems connecting. It turns out most folks that are having problems are using windows 7. What is frustrating is that it sometimes works...and other times it does not.
To be specific.. If a machine has been freshly rebooted it might work. Most often the users are putting their laptops to sleep going home and it does not work. I dug into this and found that the error that was being returned was
Multiple connections to a server or shared resource by the same user, using more than one user name are not allowed. Disconnect all previous connections to the server or shared resource and try again. {http://support.microsoft.
If you see the attached code...I have some success by only passing a u/p on the first connection and then skipping that for all other connections but that did not solve the problem. At this point I started looking at shelling out to net use. If I issue the commands below it seems to resolve the issue with multiple connections.
net use * /d /y
net use /persistent:no
The issue that I run into then is that the return results from shelling out to net use are not predictable... sometimes it will return all of the results...sometimes it returns nothing. {example net use /?} If I try shelling out with "cmd /c net use /?" the rusults are about the same. That is an issue because I need to do some error trapping for bad passwords/no vpn connection/etc.
I have not found a way to set all connections to non persistent from wmi and I would rather not shell out if I don't have to. That said if I can find a predictable way of doing it I might go that direction. Any insights on this would be greatly appreciated :)
Function MapNetworkDrive(sDriveLetter,sNetworkPath,sUsername,sPassword)
On Error Resume Next 'Will continue even if there is a network error
Err.Clear 'Setting Error Value to Zero
Set GetDrive = CreateObject("WScript.Network")
If sUsername="" Or sPassword="" Then
GetDrive.MapNetworkDrive sDriveLetter, sNetworkPath,False
Else
GetDrive.MapNetworkDrive sDriveLetter, sNetworkPath,false,sUserName,SPassword
End If
MapNetworkDrive = Err.Number
End Function
Function RemoveNetworkDrive(sDriveLetter)
On Error Resume Next 'Will continue even if there is a network error
Err.Clear 'Setting Error Value to Zero
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive sDriveLetter,true,true
RemoveNetworkDrive = Err.Number
End Function
Function Shell(sCommand)
Dim oShell, oExec, sLine
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec(sCommand)
Do While Not oExec.StdOut.AtEndOfStream
sLine = oExec.StdOut.ReadLine
WScript.StdOut.WriteLine "Output: " & sLine
WScript.Sleep 10
Loop
Do While oExec.Status = 0
WScript.Sleep 100
Loop
End Function
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36:
Access this solution immediately by signing up as a member of VBScriptExperts.com--it’s quick, easy, and secure. We will return you to this solution, unlocked, when you’re done.
RQuadling
5,040
0 points yesterday
Profilebillprew
4,000
0 points yesterday
Profilesirbounty
3,600
0 points yesterday
ProfileRobSampson
2,600
0 points yesterday
Profilerdivilbiss
2,000
0 points yesterday
Profileweellio
2,000
0 points yesterday
ProfileHickory420
2,000
0 points yesterday
Profileitkamaraj
1,600
0 points yesterday
Profilevadimrapp1
600
0 points yesterday
ProfileDaz_1234
400
0 points yesterday
Profile
Posted on 2010-01-10 at 12:28:42ID: 28086757
All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.