Forum Home
Press F1
 
Thread ID: 79132 2007-05-09 01:56:00 Network drives disconnect on logoff Greven (91) Press F1
Post ID Timestamp Content User
548531 2007-05-09 01:56:00 I'm mapping network drives with a vbscript on the server, but when the users log off, the drives mapped by the scripts disconnect.
How do I make the drives stay available (they are already set to sync through offline files) when the laptops aren't connected to the network when they log on?
Greven (91)
548532 2007-05-09 04:51:00 Can you post the script so we can see what you are doing? CYaBro (73)
548533 2007-05-09 05:00:00 Can you post the script so we can see what you are doing?


'Created: 26/04/2007 12:22:12 p.m.
'Author: STJOHNS\Administrator
'Created by SAPIEN Technologies, Inc. Logon Script Generator
'**********************

On Error Resume Next
Dim objFSO,objFILE,objShell,objNetwork,strHomePath
set objFSO=CreateObject( " Scripting.FileSystemObject " )
set objShell=CreateObject( " Wscript.Shell " )
set objNetwork=CreateObject( " Wscript.Network " )


'Map network drives
MapIt " S: " , " \\server\groups$\students "
MapIt " H: " , " \\server\users$\ " & objNetwork.UserName
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserN ame, " Office " ) Then MapIt " O: " , " \\server\groups$\office "
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserN ame, " Teachers " ) Then MapIt " T: " , " \\server\groups$\teachers "
If IsAMemberOf(objNetwork.UserDomain,objNetwork.UserN ame, " Office " ) Then MapIt " T: " , " \\server\groups$\teachers "



'End of main script

'//////////////////////////////////////////////////
Function PasswordExpires(strDomain,strUser)
On Error Resume Next
Dim objUser
Set objUser=GetObject( " WinNT:// " & strDomain & " / " & strUser & " ,user " )
PassExp=INT(objUser.MaxPasswordAge/86400)-INT(objUser.PasswordAge/86400)

If PassExp<0 Then
strPassMsg= " Your password never expires. "
Else
strPassMsg= " Your password expires in " & PassExp & " day(s) "
end If

PasswordExpires=strPassMsg
End Function

Function IsAMemberOf(strDomain,strUser,strGroup)
On Error Resume Next
Set objUser=GetObject( " WinNT:// " & strDomain & " / " & strUser & " ,user " )
Set objGrp=GetObject( " WinNT:// " & strDomain & " / " & strGroup & " ,group " )

If objGrp.IsMember(objUser.ADsPath) Then
IsAMemberOf=True
Else
IsAMemberOf=False
End If

End Function

Sub MapIt(strDrive,strMap)
On Error Resume Next
If objFSO.DriveExists(strDrive) Then objNetwork.RemoveNetworkDrive(strDrive)

objNetwork.MapNetworkDrive strDrive,strMap

If Err.Number<>0 And blnShowError Then
strMsg= " There was a problem mapping drive " & UCase(strDrive) & " to " & _
strMap & VbCrLf & strHelpMsg & VbCrLf & " Error#: " & Hex(err.Number) & _
VbCrLf & Err.Description
objShell.Popup strMsg,iErrorTimeOut, " Error " ,vbOKOnly+vbExclamation
Err.Clear
End If

End Sub

Sub AddPrinterConnection(strPrinterUNC)
On Error Resume Next

objNetwork.AddWindowsPrinterConnection strPrinterUNC

If Err.Number<>0 And blnShowError Then
strMsg= " There was a problem mapping " & UCase(strPrinterUNC) & " . " & _
vbcrlf & VbCrLf & strHelpMsg & VbCrLf & " Error#: " & Hex(err.Number) & _
VbCrLf & Err.Description

objShell.Popup strMsg,iErrorTimeOut, " Error " ,vbOKOnly+vbExclamation
Err.Clear
End If

end sub

Sub AddPrinterPortConnection(strPort,strPrinterUNC)
On Error Resume Next

objNetwork.AddPrinterConnection strPort,strPrinterUNC

If Err.Number<>0 And blnShowError Then
strMsg= " There was a problem mapping " & UCase(strPrinterUNC) & " to " & _
strPort & vbcrlf & VbCrLf & strHelpMsg & VbCrLf & " Error#: " & Hex(err.Number) & _
VbCrLf & Err.Description

objShell.Popup strMsg,iErrorTimeOut, " Error " ,vbOKOnly+vbExclamation
Err.Clear
End If

end sub
Greven (91)
548534 2007-05-09 06:47:00 Pretty sure this is what you need to do:

Change this line:

objNetwork.MapNetworkDrive strDrive,strMap

to this:

objNetwork.MapNetworkDrive strDrive,strMap,True
CYaBro (73)
1