I use a function that I created called checkandsetregvalue which is self explanatory. This sets the necessary registry settings for my mapped drives to work
;================================================================================================
; Checks the registry value and if incorrect, it applies correct setting, otherwise says already applied
;================================================================================================
Function CheckAndSetRegValue($RegPath, $RegValue, $RegData, $RegType)
$ReturnValue = ReadValue($RegPath, $RegValue)
If ($ReturnValue = $RegData)
; ? "Registry value already applied:"
; ? "Path: " + $RegPath
; ? "Value: " + $RegValue
; ? "RegData: " + $RegData
; ? "Value Type: " + $RegType
Else
WriteValue($RegPath, $RegValue, $RegData, $RegType)
; ? "Registry value is being set for: "
; ? "Path: " + $RegPath
; ? "Value: " + $RegValue
; ? "RegData: " + $RegData
; ? "Value Type: " + $RegType
EndIf
EndFunction
;=================================================================
; Delete Persistent Network connections ie mapped drives
;=================================================================
CheckAndSetRegValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Network\Persistent Connections", "SaveConnections", "No","REG_SZ")
;======================================================================================================
;This setting fixes a problem with mapped drives not working with domain users in windows 7 - something to do with uac
;======================================================================================================
CheckAndSetRegValue($HKLMSOFT + "\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLinkedConnections", "1", "REG_DWORD")
;=============================================================
; Maps user drives
;=============================================================
Use X: $ServerName + "\software"
If ingroup ("managers") or ingroup ("office") = 1
? "Do not map P drive as don't need for these users"
Else
;=================================================================
; Mapping the P: drive for staff and pupils
;=================================================================
Use P: $ServerName + "\shared\access"
Endif
Allen has mentioned that one should not use "EnableLinkedConnections", so you might want to look up his alternative that he suggested. I have not had time to look into that as yet.
On my test server (windows 2008 server) I have noticed the problem with the red crossed on drives that I have manually mapped on my server (with the setting to map again for every logon. This is not a script issue, its a windows vista/7 issue to do with persistent mappings.
Rob