;; 
;;=====================================================================================----- 
;; 
;;FUNCTION       SvcList() - DEPRECATED in ITCG CODING - SEE WMISvcMgr() 
;; 
;;ACTION         Returns a list of system services an dtheir status 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.0  - 2002/04/19 
;; 
;;HISTORY        1.0  - 2002/04/19 - Initial Release 
;; 
;;SYNTAX         SvcList([Service, Server]) 
;; 
;;PARAMETERS     Service - Optional - String 
;;               - The name of a specific service. 
;; 
;;               Server - Optional - String 
;;               - The name of a remote server to target. 
;; 
;;REMARKS        Returns status of all services, or details of a single service 
;; 
;;RETURNS        Array of comma-delimited service info (Short_Name, Long_Name, Status) 
;;               Array of specific service detail information 
;; 
;;DEPENDENCIES   xnet.exe	Kixtart component - must be available in the PATH, or 
;;               have it's location defined by %S_BIN% or @SCRIPTDIR 
;;               GetTmpFN()	Kix UDF 
;; 
;;TESTED WITH    NT4, W2K, WXP 
;;               Explicit, NoVarsInStrings 
;; 
;;EXAMPLES        
; 
Function SvcList(Optional $_fService, Optional $_Target)
 
  Dim $_aTmp[250]
  Dim $_, $_ID, $_Dat, $_Pos, $_Quote, $_Single, $_Cmd, $_FH, $_Line, $_TFile, $_Over, $_CPath
 
  $_TFile = GetTmpFN('SL')
 
  ; Locate the XNET.EXE command 
  $_CPath = IIf(Exist('%S_BIN%\xnet.exe'),'%S_BIN%\', '')	; default to PATH, look in %S_BIN% 
  $_CPath = IIf($_CPath = '' And Exist(@SCRIPTDIR + '\xnet.exe'), @SCRIPTDIR + '\', $_CPath)
 
  $_Pos   = 0
  $_Quote = IIf($_fService, '"', '')
 
  ; insure proper format of server name, if specified 
  $_Target =  IIf(CStr($_Target) <> '', '\\' + Join(Split(CStr($_Target), '\'), '', 3) + '\', '')
 
 
  ; are we doing all services, or one specific service? 
  $_Single = IIf($_fService, 1, 0)
  If $_Single
    $_aTmp[6] = 'Stopped'
  EndIf
 
  ; Run the command to collect the data 
  $_Cmd = '%ComSpec% /c ' + $_CPath + 'XNet List ' + $_Quote + $_Target + $_fService + $_Quote + ' >"' + $_TFile + '"'
  Shell $_Cmd
 
  ; Parse the data file 
  If GetFileSize($_TFile) > 0
    $_FH = FreeFileHandle()
    If Open($_FH, $_TFile) = 0
      $_Line = ReadLine($_FH)
 
      While @ERROR = 0
        If $_Single
          If InStr($_Line, 'Failed')
            $_ = Close($_FH)
            Del $_TFile
            Exit Split(Split($_Line, '[')[1], ' ')[0]
          EndIf	; error if service doesn't exist 
          $_ID  = Left($_Line, 3)
          $_Dat = SubStr($_Line, 15, Len($_Line) - 14)
          ; which row of data do we have? 
          $_Pos = InStr('DisBinStaAccLoaDepSer', $_ID) - 1
          ; is the position valid? 
          If $_Pos Mod 3 = 0
            $_Pos = $_Pos / 3
            $_aTmp[$_Pos] = $_Dat
          EndIf
 
        Else	; all services 
 
          $_Dat = Left($_Line, 10)
          If InStr('ServiceNam----------', $_Dat) = 0
            ; Handle badly named services - adjust the short name length by the number of positions over 69 
            ; xnet always trims the display name to a maximum length, but the short name can exceed the normal 
            ; format limit. 
            $_Over = Len($_Line) - 69
            $_aTmp[$_Pos] = Trim(Left($_Line, 31 + $_Over)) + ',' + Trim(SubStr($_Line,32 + $_Over,31)) + ',' + Trim(SubStr($_Line,63 + $_Over,14))
            $_Pos = $_Pos + 1
          EndIf	; not Header data 
 
        EndIf	; SingleService 
 
        $_Line = ReadLine($_FH)
 
      Loop
 
      If $_Single 
        $_Pos = $_Pos + 1	; Account for pre-loaded value! 
      EndIf
 
      $_ = Close($_FH)
 
    EndIf	; Open File 
  Else
    Del $_TFile	; Delete the file 
    Exit 2
  EndIf
 
  Del $_TFile	; Delete the file 
 
  ; get rid of null array entries 
  $_Pos = IIf($_Single, $_Pos, $_Pos - 1)
  ReDim Preserve $_aTmp[$_Pos]
 
  ; return the array 
  $SvcList = $_aTmp
 
  Exit 0
 
EndFunction