Jump to content

need help to get the list of features into array


Recommended Posts

hello autoit team

please i need your help today

am trying to make the list of features in list view and control it

am using the dism command line to read output

i've made the code

but i found some problems

what i need is the list of features in 2d array

$array[$n][0]= name $array[$i][1] = state

when i tested the code

it give me some results that i don't need to it e.g

------ ------  | --------

or

name       | state

i need just the list of features and there state

please help me to do that

here is my example

#RequireAdmin
#NoTrayIcon
#include <AutoItConstants.au3>
Wow64EnableWow64FsRedirection(false)
_Windows_Get_Features()
func _Windows_Get_Features()
local $a_FeaturesArray[1][2]
$a_FeaturesArray[0][0]
local $i_Dism_Run = Run("DISM /online /english /get-features /format:table", "", @sw_hide, BitOR($STDERR_CHILD, $STDOUT_CHILD))
local $s_OutputDism = "", $a_OutPutDism
While 1
$s_OutputDism = StdoutRead($i_Dism_Run)
        If @error Then exitLoop
if ($s_OutputDism = "") or (StringRegExp($s_OutputDism, "^((\-){1,})?(?:\s)\|?(?:\s)((\-){1,})$", 0) = 1) then ContinueLoop
if (StringRegExp($s_OutputDism, "((([\s\d\-\+\_\,]{1})\|([\s\d\-\+\_\,]{1})){1,})", 0) = 1) then
$a_OutPutDism = StringSplit($s_OutputDism, @lf)
for $i = 1 to $a_OutPutDism[0]
if msgBox(1, $i, $a_OutPutDism[$i]) = 1 then exitLoop
next
endIf
Wend
endFunc

func Wow64EnableWow64FsRedirection($b_Enabled)
local $h_OpenFS = DLLOpen("kernel32.dll")
local $Return = DllCall($h_OpenFS, "boolean", "Wow64EnableWow64FsRedirection", "boolean", $b_Enabled)
if @error then
DLLClose($h_OpenFS)
Return SetError(@error, @extended, -1)
else
DLLClose($h_OpenFS)
Return $Return[0]
endIf
endFunc

 

Link to comment
Share on other sites

This :

#RequireAdmin
#NoTrayIcon
#include <AutoItConstants.au3>
#include <StringConstants.au3>
#include <Array.au3>
#include <WinAPIFiles.au3>

_WinAPI_Wow64EnableWow64FsRedirection(False)
Local $aFeature = _Windows_Get_Features()
_ArrayDisplay ($aFeature)

Func _Windows_Get_Features()
  Local $i_Dism_Run = Run("DISM /online /english /get-features /format:table", "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
  ProcessWaitClose ($i_Dism_Run)
  Local $s_OutputDism = StdoutRead($i_Dism_Run)
  Local $array = StringSplit ($s_OutputDism, @CRLF, $STR_ENTIRESPLIT), $tmp, $final [$array[0]][2], $count
  For $i = 1 to $array[0]
    $tmp = StringSplit ($array[$i], "|")
    If $tmp[0] <> 2 Or StringLeft($array[$i], 4) = "----" Or StringLeft($array[$i],12) = "Feature Name" Then ContinueLoop
    $final[$count][0] = $tmp [1]
    $final[$count][1] = $tmp [2]
    $count += 1
  Next
  ReDim $final[$count][2]
  Return $final
EndFunc   ;==>_Windows_Get_Features

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...