Hello,Here is some code I wrote to enumerate and/or delete persistent connections. You may then add whatever you want. It works for both NT and Win9x clients.
code:
;****************************************************************************************
:ENUMPERSIST
; Description:
; Enumerate all the user's persistent connections. Want to keep it in a log
; in case the user has a problem.
;
; Input:
; $OS, $HKCU, $user
;
; Output:
; None
;****************************************************************************************
; Modification History
; Date Initials Description
; 11 Aug 98 bvv Wrote first cut.
;****************************************************************************************
;
Dim $index, $persist, $loop_index, $name, $keyname, $p_name, $returncode
$index=0
If $OS="Win9x"
$persist="$HKCU\Network\Persistent"
Else
$persist="$HKCU\Network"
Endif
? "Enumerate the persistent connections: "+$persist
$loop_index=0
While $loop_index=0
$name=EnumKey("$persist",$index)
$loop_index=@ERROR
If $loop_index=0
$keyname=$persist+"\"+$name
$p_name=ReadValue("$keyname","RemotePath")
? "The enumerated value is: "+$name+" and its UNC is: "+$p_name+"."
; If you want to delete the keys, uncomment the next few lines.
; $returncode=DelKey($keyname)
; If $returncode=0
; ? "The persistent connection to "+$p_name+" was deleted."
; ? "The index value is: "+$loop_index+"."
; Else
; ? "There was a problem deleting the persistent connection to: "+$p_name
; Endif
$index=$index+1
Else
If $loop_index=259
; This error should come up when all entries have been enumerated.
? "All persistent connections have been listed."
Else
; An unknown error has occurred.
? "An error has occurred while enumerating persistent connections. The"
? "error number is: "+$loop_index+"."
Endif
Endif
Loop
Return
;
Note: I set $OS to either "Win9x" or "Windows NT" in another subroutine; $HKCU is set to "HKEY_CURRENT_USER" and $user is set to @USERID (I always set a variable to a macro definition if I am going to use it more than once in a script).
Hope this helps.
------------------
Regards,
Brad
Consultant
Net InfraStructure, Inc