;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       GetNetConnections() 
;; 
;;ACTION         Lists network connectinos 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.0 - 2007/02/15 
;; 
;;HISTORY        1.0 - 2007/02/15 
;; 
;;SYNTAX         GetNetConnections() 
;; 
;;PARAMETERS     None 
;; 
;;REMARKS        Returns an array of network connections, each element  
;;               containing the drive letter, a comma, and the share path 
;; 
;;RETURNS        Array: d,unc path 
;; 
;;DEPENDENCIES   Access to NET command 
;; 
;;TESTED WITH    W2K, WXP, W2K3 
;; 
;;EXAMPLES       $A = GetNetConnections() 
;;               For Each $E in $A 
;;                 If InStr($E, '\\unc\path') 
;;                   '\\unc\path is mapped to drive ' Left($E,1) ':' ? 
;;                 EndIf 
;;               Next 
; 
Function GetNetConnections()
 
  Dim $TmpFile					; temporary output file 
  Dim $I					; Index var 
  Dim $L					; Line from input file 
  Dim $C[0]					; Array returned 
 
  $I = -1					; preload the array index 
 
  ; generate a unique temp file name 
  SRND(@TICKS + @PID)
  $TmpFile = '%TEMP%\nc_'+ @PID + '_' + Rnd(@TICKS) + '.txt'
 
  Shell '%COMSPEC% /c Net Use | %SYSTEMROOT%\System32\Find.exe ":" > ' + $TmpFile
 
  If Open(3, $TmpFile) = 0
    $L = ReadLine(3)				; read the input line 
    While Not @ERROR
 
      ; update the array values with the drive and share values 
      $I = $I + 1				; increment the pointer 
      ReDim Preserve $C[$I]			; redim the array to the new size 
      $C[$I] = SubStr($L, 14, 1) + ',' + Split(SubStr($L, 24), ' ')[0]
 
      $L = ReadLine(3)				; get the next line 
    Loop
 
    $ = Close(3)				; done - close the file handle 
 
  Else
    Del $TmpFile				; make sure the temp file is gone 
    Exit @ERROR
  EndIF
 
  Del $TmpFile					; delete the temp file 
 
  $GetNetConnections = $C
 
EndFunction