Question Locked

Log on / Log Off scripts

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a log on script running for my mapped drives. Every once in a while I have users telling me that they get an error saying that the mapped drives are already mapped when they try to log on to the computer shortly after they logged off and logged back on again. I thought that the drives would disconnected when the users log off. Should I have a log off script to disconnect the drives at log off. (But I need to make sure if they lock the computer the mapped drives stay connected. This is a must have feature that they DO NOT loose connect when they lock the computer.) Can anyone help out with this little issue?

Thanks to anyone who helps!!

5 replies

by sgt_shultz

net use m: \\server\share /persistent:no

did you try that one?

by jdclyde

Did you know Sonja has been trying to contact you?

by mike barron

I use VBS to map drives and make them persistent. I find that this works better than BAT files.

This script maps a drive, names it and makes it persistent.

Option Explicit
Dim objNetwork, strDrive, objShell, objUNC
Dim strDriveLetter
Dim strRemotePath
Dim strNewName
Dim bForce, bUpdateProfile

strDriveLetter = "J:"
strRemotePath = "\\server.domain.com\public"
strNewName = "Public"
bForce = "True"
bUpdateProfile = "True"

Set objNetwork = CreateObject("WScript.Network")
On Error Resume Next
objNetwork.RemoveNetworkDrive strDriveLetter, bForce, bUpdateProfile
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, true

Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter1).Self.Name = strNewName

by robert.kent

Here is an example that I found when I wrote the log on script. I am not very good writing VBS scripts.

' TwoMap.vbs - Map Network Drive to M: and P:
' Example of VBScript Mapping two drives in one script.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.6 - April 24th 2005
' -----------------------------------------------------------------'
Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2
Dim strDriveLetter1, strDriveLetter2

strDriveLetter1 = "M:"
strDriveLetter2 = "P:"
strRemotePath1 = "\\alan\drivers"
strRemotePath2 = "\\alan\downloads reports"

Set objNetwork = CreateObject("WScript.Network")

' Section which maps two drives, M: and P:
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2

' Extra code just to add a message box
WScript.Echo "Map drives " & strDriveLetter1 & " & " & strDriveLetter2

Wscript.Quit

' End of Windows Logon Script Example

How would I mod this code to get similar to your code?

This discussion is closed to new replies.