;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       ShadowCopyDrives() 
;; 
;;ACTION         Returns a list of drives with ShadowCopy enabled 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;CONTRIBUTORS    
;; 
;;VERSION        1.1  - 2020/06/26 
;; 
;;HISTORY        1.0  - 2015/09/09 - Initial release 
;;               1.1  - 2020/06/26 - Update to use WshPipe UDF - suppress window  
;;                                   flash/pop-up with WMIexec method 
;; 
;;SYNTAX         ShadowCopyDrives([WorkDir]) 
;; 
;;PARAMETERS     WorkDir - OPTIONAL - String - path to working folder, defaults 
;;               to %TEMP% if not specified. 
;; 
;;REMARKS        Returns an array of drive letters that have shadow copy enabled 
;; 
;;RETURNS        Array of strings 
;; 
;;DEPENDENCIES   WSHPipe UDF, vssadmin.exe 
;; 
;;TESTED WITH    W2K3, W2K8, W2K12 
;; 
;;EXAMPLES       'Drives with Shadow Copy enabled: ' Trim(Join(ShadowCopyDrives(), ' ')) @CRLF 
; 
Function ShadowCopyDrives(OPTIONAL $_WorkDir)
 
  Dim $_Cmd					; command to execute 
  Dim $_aData                                   ; command result array 
  Dim $_aResult[0]				; result array 
  Dim $_D, $_P					; current & prior data values 
  Dim $_I					; Array index 
 
  If Not $_WorkDir $_WorkDir = '%TEMP%' EndIf
 
  $_Cmd = '%COMSPEC% /c %WINDIR%\SysNative\vssadmin.exe List Shadows | find /i "original volume"'
  $_aData = WshPipe($_Cmd)[0]
 
  For Each $_D in $_aData
    $_P = ''
    $_I = -1
    $_D = Split(Split($_D, '(')[1], ')')[0]	; get the drive letter 
    If Trim($_D)
      If Not Instr($_P, $_D)			; If not seen previously 
        ; add the data to the array 
        $_I = $_I + 1				; increment index pointer 
        ReDim Preserve $_aResult[$_I]		; increase the array 
        $_aResult[$_I] = $_D			; add the element 
        $_P = $_P + $_D				; identify the previous 
      EndIf
    EndIf
  Next
 
  $ShadowCopyDrives = $_aResult
  Exit 0
 
EndFunction