Hi,
I am currently trying to map an extra network drive for pupils on log on.
We use simple bat files normally and this works fine for us for now, however I am trying to use a VB as this script needs to be a little more complex.
The script checks the first two characters of the computer name and then only allows a network drive to map for certain machines (by room number).
I can get this to work with any admin or staff account, but not a pupil account. I believe that this is due to restrictions we have set up to 'lockdown' our network. I have tried researching adding user credentials into the script but always receive the same error message when running the code.
Following this message I have tried a bit of script to remove cached user credentials, to no avail."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.."
Here is my script so far... maybe a little messy, but i'm only just learning.
I beleive this to remove cached credentials, but as I said, I couldn't get it to work.PHP Code:set shell = WScript.CreateObject( "WScript.Shell" )
computername = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
If (left(computername,2)) = "D2" Or (left(computername,2)) = "D3" Or
(left(computername,2)) = "D4" Or (left(computername,2)) = "D5" Then
wscript.echo ("This test was a success!")
Dim objNetwork, strRemotePath1, strDriveLetter1
strDriveLetter1 = "T:"
strRemotePath1 = "\\Server\Share"
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
ElseIf (left(computername,2)) = "SV" Then
wscript.echo ("This test was a successful failure!")
Else
wscript.echo ("This test was a failure!")
wscript.Quit
End if
And finally the adding user credentials section.PHP Code:strServer = "servername"
strCommand = "cmd /c cmdkey /delete:" & strServer
objShell.Run strCommand, 0, True
Any help would be greatly appreciated, or even just tell me that i'm going the wrong way about achieving what I set out to.PHP Code:Set objNetwork = WScript.CreateObject("WScript.Network")
strDriveLetter1 = "L:"
strRemotePath1 = "\\server\share"
strPer1 = "FALSE"
strUsr1 = "username"
strPas1 = "password"
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, strPer1, strUsr1, strPas1
Thanks,
Pete


LinkBack URL
About LinkBacks



