Acidburn -
This is what I use to delete ALL static mappings on clients. 1st part shows how variable $Priviledge calculated, 2nd part process to remove Persistent Mappings.Of course, if other script mapping \\server\f$ run after this script, no change will be made.
Bill
BTW: Welcome to the board!
code:
; REM ** 4. Define_user privilege. Note: For 'INGROUP \\@WKSTA' to work properly you must create a Global Domain group,
; REM ** add Admin/Power Users to this group, then add the Global group to local workstation Admin/Power Users groups.
SELECT
CASE INGROUP ("Domain Admins") $Privilege = "Domain Admin"
CASE INGROUP ("\\@WKSTA\Administrators") $Privilege = "Local Admin"
CASE INGROUP ("\\@WKSTA\Power Users") $Privilege = "Power User"
CASE (1) $Privilege = "User"
ENDSELECT
:DelPersistent
; rem ####################################################################
; rem ## Delete Registry Persistent drive mappings. Check in case ##
; rem ## end users add drive mappings outside defined login-script. ##
; rem ## DECREMENTING index is most efficient to insure all removed. ##
; rem ####################################################################
; REM ** Local variables in use by this function are:
$EmailMsg = "Could not delete persistent drive mappings on computer @WKSTA."
$ErrorMsg = "Could not delete persistent drive mappings on computer @WKSTA."
$Err = " "
$RegKey = "HKEY_CURRENT_USER\Network"
IF ((@INWIN = 1) AND ($Privilege = "User"))
$con = WRITELINE (10, "User does not have permissions to delete persistent drive mappings." + $CR)
$Status = $Skip
RETURN
ENDIF
$x2=23 ; REM ** Covers letters D-Z
DO
$RC = ENUMKEY ("$RegKey", $x2)
SELECT
CASE (@ERROR = 0)
DELKEY ("$RegKey\$RC")
SELECT
CASE (@ERROR = 0) $Status = $OK
CASE (@ERROR <> 0) $Err = "1"
ENDSELECT
CASE (@ERROR <> 0) AND ($Err = "1") GOSUB ScriptError RETURN
CASE (1) RETURN
ENDSELECT
$x2=$x2-1
UNTIL $x2 < 0
RETURN
[This message has been edited by bleonard (edited 14 June 2001).]