Jump to content

send key tab jumps somewhere else


Go to solution Solved by ioa747,

Recommended Posts

8 minutes ago, ioa747 said:

main console out:

$CmdLine[0]=4
$hGPO=0x000000000021065E
--- $sPolicyPath=Local Computer Policy\Computer Configuration\Administrative Templates\Windows Components\Connect
--- $sPolicyItem=Require pin for pairing
--- $iSetting=1
--- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Connect
- $FindItem=1
- $SelectedItem=1
$ItemTxt[0]=Require pin for pairing
$ItemTxt[1]=Not configured
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x00000000000E0D8E
> $hGPOedit=normal <
-> Enabled
- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
- $SelectedItem=1
$ItemTxt[0]=Require pin for pairing
$ItemTxt[1]=Enabled
$ItemTxt[2]=No
$ItemTxt[3]=

post yours

very strange from SciTE it is work but from exe not work why? how do you do compile?

$CmdLine[0]=4
$hGPO=0x0000000000B303BC
--- $sPolicyPath=Local Computer Policy\Computer Configuration\Administrative Templates\Windows Components\Connect
--- $sPolicyItem=Require pin for pairing
--- $iSetting=1
--- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Connect
- $FindItem=1
- $SelectedItem=1
$ItemTxt[0]=Require pin for pairing
$ItemTxt[1]=Not configured
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x00000000005F08EE
> $hGPOedit=normal <
-> Enabled
- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
- $SelectedItem=1
$ItemTxt[0]=Require pin for pairing
$ItemTxt[1]=Enabled
$ItemTxt[2]=No
$ItemTxt[3]=

 

Link to comment
Share on other sites

7 hours ago, ioa747 said:

I don't know, no I didn't compile  it,

I'll see it later I have to go

It behaves sometimes works not. Does not always close the GPO. 

so I deleted this line 

#AutoIt3Wrapper_UseX64=y

compile x64 it still changes something else but also the  "Require pin for pairing"

you can see the video  
https://www.dropbox.com/s/xo1wapciwxswzto/Require pin for pairing.mp4?dl=0
still not close gpo

Edited by gal9
Link to comment
Share on other sites

5 hours ago, ioa747 said:

I don't know, no I didn't compile  it,

I'll see it later I have to go

and I try to create a script to export go to path and do export by default it will be "\Computer Configuration\Administrative Templates\All Settings"  :
It behaves strange sometimes works sometimes doesn't

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit
;   $CmdLine[3] - $iSetting    - T0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey"
;==============================================================
; EXAMPLES:
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0                                                          ; * - Normal
; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 3   ; * - Special
; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f"       ; * - With Option
; Global $CmdLine[5] = [4, "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0]

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"
    $CmdLine[2] = "Require pin for pairing"
    $CmdLine[3] = 3
    $CmdLine[4] = "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" ;optional
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
EndIf

Exit

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "")
Local $sDirPath ="C:\share\GPO-Export\" & @YEAR & "-" &@MON& "-"  & @MDAY
Local $sFilepath = $sDirPath & "--" & @HOUR& "-"  & @MIN  & "-"& @SEC

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinWait("Local Group Policy Editor", '', 5)

    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")
    Sleep(50)

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("--- $sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("--- $sPolicyItem=" & $sPolicyItem & @CRLF)
    ConsoleWrite("--- $iSetting=" & $iSetting & @CRLF)
    ConsoleWrite("--- $sOption=" & $sOption & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""
    Sleep(50)

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
            Sleep(50)

        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
            Sleep(50)

        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next
    Sleep(50)

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")
    Sleep(50)


    ControlSend($hGPO, "", $hTreeView_1, "{ALT}{A}{L}")
        Sleep(50)

    ControlFocus($hGPO, "", "[TITLE:Export List]")
    Sleep(50)

    WinWait("[TITLE:Export List]")
    ControlSend("[TITLE:Export List]", "", "", "{TAB}")
        Sleep(3000)
    ControlSend("[TITLE:Export List]", "", "", "{down}{down}")
    ControlSend("[TITLE:Export List]", "", "", "{Enter}")
    Sleep(3000)

    ControlSend("[TITLE:Export List]", "", "", "{ALT down}{n}{ALT up}")
    ControlSend("[TITLE:Export List]", "", "", $sFilepath)
    ControlSend("[TITLE:Export List]", "", "", "{Enter}")



    ;---------------------------------------------------------------

    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)



;~  Exit  ; <-- ****************************************************

    Sleep(50)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    $hGPO = WinWait("Microsoft Management Console", "", 1)
    ControlSend($hGPO, "", "Static2", "{N}")

    Return $sPolicyItem

EndFunc   ;==>_GroupPolicy
;----------------------------------------------------------------------------------------

in past i saved gpo in All Settings and do this code:
 

#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win9x/NT
; Author:         Jonathan Bennett (jon at autoitscript dot com)
; Modified:       mLipok
;
; Script Function:
;   Opens Notepad, types in some text and then quits the application.
;



_Example()



Exit(0)

; Finished!
; Func _ChangeName($i)
;   While 1
    ;       Send("{enter}")
    ;       Send($pathToSaveCSV&"--"& $i)
    ;       Send("{Enter}")
    ;   If  WinWaitActive("[TITLE:Confirm Save As]", "", 1) Then
    ;               $i += 1
    ;   EndIf
    ;   If WinWaitActive("[CLASS:MMCMainFrame]", "", 1) Then
    ;   ;Send("{ALT down}{F4}{ALT up}")
    ;   Return 1
    ;   EndIf
    ; WEnd
; EndFunc







Func _Example()
    Global $i = 1
Local $sDirPath ="C:\share\GPO-Export\" & @YEAR & "-" &@MON& "-"  & @MDAY
Local $sFilepath = $sDirPath & "--" & @HOUR& "-"  & @MIN  & "-"& @SEC

MsgBox(4096, "message", "Start export validation csv", 3)

    ; Run gpedit.msc
    ; Run("c:\Windows\system32\mmc.exe c:\Windows\system32\gpedit.msc /a")
    Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")

    Sleep(2500)


    Local $hGPO = WinWait("Local Group Policy Editor")
    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")


    Sleep(500)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT}{A}{L}")
    ControlFocus($hGPO, "", "[TITLE:Export List]")

    WinWait("[TITLE:Export List]")
    ControlSend("[TITLE:Export List]", "", "", "{TAB}")
        Sleep(3000)
    ControlSend("[TITLE:Export List]", "", "", "{down}{down}")
    ControlSend("[TITLE:Export List]", "", "", "{Enter}")
    Sleep(3000)

    ControlSend("[TITLE:Export List]", "", "", "{ALT down}{n}{ALT up}")
    ControlSend("[TITLE:Export List]", "", "", $sFilepath)
    ControlSend("[TITLE:Export List]", "", "", "{Enter}")





ControlFocus($hGPO, "", $hTreeView_1)
ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

Sleep(2000)
    Local $hGPO = WinWait("Microsoft Management Console")

ControlSend($hGPO, "", "[CLASS:Static; INSTANCE:2]", "{N}")

Sleep(2000)
MsgBox(4096, "message", "Finish export validation csv", 3)

EndFunc

 

Edited by gal9
Link to comment
Share on other sites

11 hours ago, gal9 said:

and I try to create a script to export

what do you want to export?, for what purpose?

  1. I changed the name to _GroupPolicy3
  2. *New Setting
    $iSetting    - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
    Export item data to _GroupPolicy3.value if you want read the value on other program, or as example with what do you want to export.
  3. Ad _GroupPolicy3.log to check if error when call it externally 
  4. And ad the  Ini.File  switch
    if  $CmdLine[2] - $sPolicyItem = "Ini.File"
    and  $CmdLine[1] - $sPolicyPath = the ini file path
    then it can setting all items from the ini file

_GroupPolicy3.au3

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=0.0.0.12
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=_GroupPolicy3.au3
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate ; if Ini.File switch then the ini file path
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit ; Ini.File switch
;   $CmdLine[3] - $iSetting    - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey"
;==============================================================
; EXAMPLES:
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0                                                          ; * - Normal
; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 3   ; * - Special
; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f"       ; * - With Option
; "\Computer Configuration\Administrative Templates\All Settings", "Allow Adobe Flash", 3                                                                               ; * - All Settings
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 4                                                          ; * - Export.value
; @ScriptDir & "\set_01.ini", "Ini.File", 0                                                                                                                             ; * - Ini.File switch


If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = @ScriptDir & "\set_00.ini"
    $CmdLine[2] = "Ini.File"
    $CmdLine[3] = 0
    $CmdLine[4] = "" ;optional
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)
ConsoleWrite("$CmdLine[1]=" & $CmdLine[1] & @CRLF)
ConsoleWrite("$CmdLine[2]=" & $CmdLine[2] & @CRLF)
ConsoleWrite("$CmdLine[3]=" & $CmdLine[3] & @CRLF)
ConsoleWrite("$CmdLine[4]=" & $CmdLine[4] & @CRLF)

Global $Txt = "=================================="
$Txt &= "=================================="
$Txt &= "==================================" & @CRLF

$Txt &= "$CmdLine[0]=" & $CmdLine[0] & @CRLF
$Txt &= "$CmdLine[1]=" & $CmdLine[1] & @CRLF
$Txt &= "$CmdLine[2]=" & $CmdLine[2] & @CRLF
$Txt &= "$CmdLine[3]=" & $CmdLine[3] & @CRLF
$Txt &= "$CmdLine[4]=" & $CmdLine[4] & @CRLF


If Not WinExists("Local Group Policy Editor") Then
    Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
EndIf

;Retrieves the 'Local Group Policy Editor' window handle
Global $hGPO = WinWait("Local Group Policy Editor", '', 5)

ConsoleWrite("$hGPO=" & $hGPO & @CRLF)
$Txt &= "$hGPO=" & $hGPO & @CRLF

;Retrieves the SysTreeView321 control handle
Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

;Ini.File switch
If $CmdLine[2] = "Ini.File" Then
    ReadIni($CmdLine[1])
EndIf

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
    $Txt &= "incorect number of parameters:" & $CmdLine[0]
    GPOExit()
EndIf

GPOExit()

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        $Txt &= "$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;find the item
    Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(1000)
    ConsoleWrite("- $FindItem=" & $FindItem & @CRLF)
    $Txt &= "- $FindItem=" & $FindItem & @CRLF

    ;If not found then Return Error
    If $FindItem = -1 Then
        ConsoleWrite("not found the entry:'" & $sPolicyItem & "'" & @CRLF)
        $Txt &= "not found the entry:'" & $sPolicyItem & "'" & @CRLF
        ;Return SetError(1, 0, "")
        GPOExit()
    EndIf

    ;select the found item
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)
    Sleep(50)

    ;snap Selected Item
    Local $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    Local $ItemTxt[4]
    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    ;$iSetting=4=>Export.value
    If Int($iSetting) = 4 Then
        Local $sValue = ""
        ConsoleWrite("- $iSetting=Export.value" & @CRLF)
        $Txt &= "- $iSetting=Export.value" & @CRLF
        For $i = 0 To 3
            $sValue &= $ItemTxt[$i] & ", "
        Next
;~      $sValue = StringTrimRight($sValue, 2) & StringReplace(StringTrimRight($tmpPath, 1), "|", "\")
        $sValue = StringTrimRight($sValue, 2)
        _SetFile(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".value", $sValue)

        GPOExit()

    EndIf

    ;and send enter to open it
    ControlSend($hGPO, '', $hListView, '{ENTER}')

    ;---------------------------------------------------------------

    Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]", "", 1)
    ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)
    $Txt &= "- $hGPOedit=" & $hGPOedit & @CRLF

    If WinExists($hGPOedit) Then ; normal <-
        ConsoleWrite("> $hGPOedit=normal <" & @CRLF)
        $Txt &= "> $hGPOedit=normal <" & @CRLF
        Switch $iSetting
            Case 0 ;Disabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
                ConsoleWrite("-> Disabled" & @CRLF)
                $Txt &= "-> Disabled" & @CRLF

            Case 1 ;Enabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
                ConsoleWrite("-> Enabled" & @CRLF)
                $Txt &= "-> Enabled" & @CRLF

                If StringLen($sOption) > 0 Then
                    ConsoleWrite("- $sOption=" & $sOption & @CRLF)
                    $Txt &= "- $sOption=" & $sOption & @CRLF
                    Local $aOpt = StringSplit($sOption, ";", 1)
                    ControlSend($hGPOedit, "", $aOpt[1], $aOpt[2])
                EndIf

            Case 2 ;Configured
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c")
                ConsoleWrite("-> Configured" & @CRLF)
                $Txt &= "-> Configured" & @CRLF

            Case 3 ;find & exit
                ConsoleWrite("-> find & exit" & @CRLF)
                $Txt &= "-> find & exit" & @CRLF
                GPOExit(1)

        EndSwitch

        ;Apply
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "a")

        ;Enter
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "{ENTER}")

    Else ;special <-

        $hGPOedit = WinWait("[CLASS:#32770]", "", 1)

        ;Retrieve the window text of the active window.
        Local $sText = WinGetText($hGPOedit)
        ;ConsoleWrite($sText & @CRLF)
        If StringLeft($sText, 22) = "Local Security Setting" Then  ; * <- if "Local Security Setting"
            ConsoleWrite("> $hGPOedit=special <" & @CRLF)
            $Txt &= "> $hGPOedit=special <" & @CRLF
            Switch $iSetting
                Case 0 ;Disabled
                    ControlSend($hGPOedit, "", "Button3", "s")
                    ConsoleWrite("-> Disabled" & @CRLF)
                    $Txt &= "-> Disabled" & @CRLF

                Case 1 ;Enabled
                    ControlSend($hGPOedit, "", "Button2", "e")
                    ConsoleWrite("-> Enabled" & @CRLF)
                    $Txt &= "-> Enabled" & @CRLF

                Case 3 ;find & exit
                    ConsoleWrite("-> find & exit" & @CRLF)
                    $Txt &= "-> find & exit" & @CRLF
                    GPOExit(1)

            EndSwitch
            ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}")
            Sleep(50)

            If WinExists("Confirm Setting Change") Then
                ControlSend("Confirm Setting Change", "", "Button1", "y") ; yes
            EndIf

        EndIf

    EndIf

    ;---------------------------------------------------------------

    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    ConsoleWrite("----------------------------------------" & @CRLF)
    $Txt &= "----------------------------------------" & @CRLF

    Return $ItemTxt[1]

EndFunc   ;==>_GroupPolicy
;-------------------------------------------------------------------------------
Func GPOExit($IgnoreGPO = 0)    ; $IgnoreGPO=0 exit ; $IgnoreGPO=1 exit Ignore GPO
;~  Exit  ; <-- ****************************************************
    If $IgnoreGPO = 0 Then
        ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")
        $hGPO = WinWait("Microsoft Management Console", "", 1)
        ControlSend($hGPO, "", "Static2", "{N}")
    EndIf

    _FileWriteLog(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".log", $Txt)
    Exit

EndFunc   ;==>GPOExit
;-------------------------------------------------------------------------------
Func _SetFile($sFile, $sData, $iFormat = 266) ; FileWrite Alternative
    Local $hFileOpen = FileOpen($sFile, $iFormat)
    If $hFileOpen = -1 Then
        Return SetError(1, 0, "")
    EndIf
    Local $msg = FileWrite($hFileOpen, $sData)
    FileClose($hFileOpen)
    Return $msg
EndFunc   ;==>_SetFile
;----------------------------------------------------------------------------------------
Func ReadIni($MyIni)  ; Ini.File switch
    ConsoleWrite("Ini.File:'" & $MyIni & "'" & @CRLF)
    $Txt &= "Ini.File:'" & $MyIni & "'" & @CRLF

    Local $iniFileExists = FileExists($MyIni)
    If Not $iniFileExists Then
        ConsoleWrite("not found the ini file:'" & $MyIni & "'" & @CRLF)
        $Txt &= "not found the ini file:'" & $MyIni & "'" & @CRLF
        GPOExit()
    EndIf

    ; Read the INI section names. This will return a 1 dimensional array.
    Local $aArray = IniReadSectionNames($MyIni)

    ; Check if an error occurred.
    If Not @error Then
        Local $sPolicyPath, $sPolicyItem, $iSetting, $sOption, $sReturn
        ; Enumerate through the array to the section names.
        For $i = 1 To $aArray[0]
            ;delete the return value
            IniWrite($MyIni, $aArray[$i], "Return", "")
            
            $sPolicyPath = IniRead($MyIni, $aArray[$i], "PolicyPath", "default")
            $sPolicyItem = IniRead($MyIni, $aArray[$i], "PolicyItem", "default")
            $iSetting = IniRead($MyIni, $aArray[$i], "Setting", "default")
            $sOption = IniRead($MyIni, $aArray[$i], "Option", "")

            $sReturn = _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption)
            
            ;Write the return value
            IniWrite($MyIni, $aArray[$i], "Return", $sReturn)

        Next
    EndIf
    GPOExit()
EndFunc   ;==>ReadIni
;----------------------------------------------------------------------------------------

 

Example  set_00.ini

[step_101]
PolicyPath=\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge
PolicyItem=Allow Adobe Flash
Setting=1
Option=
Return=Enabled
[step_102]
PolicyPath=\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options
PolicyItem=Microsoft network client: Digitally sign communications (always)
Setting=1
Option=
Return=Enabled
[step_103]
PolicyPath=\Computer Configuration\Administrative Templates\Windows Components\Connect
PolicyItem=Require pin for pairing
Setting=1
Option=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
Return=Enabled

 

I know that I know nothing

Link to comment
Share on other sites

5 hours ago, ioa747 said:

what do you want to export?, for what purpose?

  1. I changed the name to _GroupPolicy3
  2. *New Setting
    $iSetting    - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
    Export item data to _GroupPolicy3.value if you want read the value on other program, or as example with what do you want to export.
  3. Ad _GroupPolicy3.log to check if error when call it externally 
  4. And ad the  Ini.File  switch
    if  $CmdLine[2] - $sPolicyItem = "Ini.File"
    and  $CmdLine[1] - $sPolicyPath = the ini file path
    then it can setting all items from the ini file

_GroupPolicy3.au3

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=0.0.0.12
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=_GroupPolicy3.au3
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate ; if Ini.File switch then the ini file path
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit ; Ini.File switch
;   $CmdLine[3] - $iSetting    - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey"
;==============================================================
; EXAMPLES:
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0                                                          ; * - Normal
; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 3   ; * - Special
; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f"       ; * - With Option
; "\Computer Configuration\Administrative Templates\All Settings", "Allow Adobe Flash", 3                                                                               ; * - All Settings
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 4                                                          ; * - Export.value
; @ScriptDir & "\set_01.ini", "Ini.File", 0                                                                                                                             ; * - Ini.File switch


If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = @ScriptDir & "\set_00.ini"
    $CmdLine[2] = "Ini.File"
    $CmdLine[3] = 0
    $CmdLine[4] = "" ;optional
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)
ConsoleWrite("$CmdLine[1]=" & $CmdLine[1] & @CRLF)
ConsoleWrite("$CmdLine[2]=" & $CmdLine[2] & @CRLF)
ConsoleWrite("$CmdLine[3]=" & $CmdLine[3] & @CRLF)
ConsoleWrite("$CmdLine[4]=" & $CmdLine[4] & @CRLF)

Global $Txt = "=================================="
$Txt &= "=================================="
$Txt &= "==================================" & @CRLF

$Txt &= "$CmdLine[0]=" & $CmdLine[0] & @CRLF
$Txt &= "$CmdLine[1]=" & $CmdLine[1] & @CRLF
$Txt &= "$CmdLine[2]=" & $CmdLine[2] & @CRLF
$Txt &= "$CmdLine[3]=" & $CmdLine[3] & @CRLF
$Txt &= "$CmdLine[4]=" & $CmdLine[4] & @CRLF


If Not WinExists("Local Group Policy Editor") Then
    Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
EndIf

;Retrieves the 'Local Group Policy Editor' window handle
Global $hGPO = WinWait("Local Group Policy Editor", '', 5)

ConsoleWrite("$hGPO=" & $hGPO & @CRLF)
$Txt &= "$hGPO=" & $hGPO & @CRLF

;Retrieves the SysTreeView321 control handle
Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

;Ini.File switch
If $CmdLine[2] = "Ini.File" Then
    ReadIni($CmdLine[1])
EndIf

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
    $Txt &= "incorect number of parameters:" & $CmdLine[0]
    GPOExit()
EndIf

GPOExit()

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        $Txt &= "$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;find the item
    Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(1000)
    ConsoleWrite("- $FindItem=" & $FindItem & @CRLF)
    $Txt &= "- $FindItem=" & $FindItem & @CRLF

    ;If not found then Return Error
    If $FindItem = -1 Then
        ConsoleWrite("not found the entry:'" & $sPolicyItem & "'" & @CRLF)
        $Txt &= "not found the entry:'" & $sPolicyItem & "'" & @CRLF
        ;Return SetError(1, 0, "")
        GPOExit()
    EndIf

    ;select the found item
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)
    Sleep(50)

    ;snap Selected Item
    Local $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    Local $ItemTxt[4]
    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    ;$iSetting=4=>Export.value
    If Int($iSetting) = 4 Then
        Local $sValue = ""
        ConsoleWrite("- $iSetting=Export.value" & @CRLF)
        $Txt &= "- $iSetting=Export.value" & @CRLF
        For $i = 0 To 3
            $sValue &= $ItemTxt[$i] & ", "
        Next
;~      $sValue = StringTrimRight($sValue, 2) & StringReplace(StringTrimRight($tmpPath, 1), "|", "\")
        $sValue = StringTrimRight($sValue, 2)
        _SetFile(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".value", $sValue)

        GPOExit()

    EndIf

    ;and send enter to open it
    ControlSend($hGPO, '', $hListView, '{ENTER}')

    ;---------------------------------------------------------------

    Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]", "", 1)
    ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)
    $Txt &= "- $hGPOedit=" & $hGPOedit & @CRLF

    If WinExists($hGPOedit) Then ; normal <-
        ConsoleWrite("> $hGPOedit=normal <" & @CRLF)
        $Txt &= "> $hGPOedit=normal <" & @CRLF
        Switch $iSetting
            Case 0 ;Disabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
                ConsoleWrite("-> Disabled" & @CRLF)
                $Txt &= "-> Disabled" & @CRLF

            Case 1 ;Enabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
                ConsoleWrite("-> Enabled" & @CRLF)
                $Txt &= "-> Enabled" & @CRLF

                If StringLen($sOption) > 0 Then
                    ConsoleWrite("- $sOption=" & $sOption & @CRLF)
                    $Txt &= "- $sOption=" & $sOption & @CRLF
                    Local $aOpt = StringSplit($sOption, ";", 1)
                    ControlSend($hGPOedit, "", $aOpt[1], $aOpt[2])
                EndIf

            Case 2 ;Configured
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c")
                ConsoleWrite("-> Configured" & @CRLF)
                $Txt &= "-> Configured" & @CRLF

            Case 3 ;find & exit
                ConsoleWrite("-> find & exit" & @CRLF)
                $Txt &= "-> find & exit" & @CRLF
                GPOExit(1)

        EndSwitch

        ;Apply
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "a")

        ;Enter
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "{ENTER}")

    Else ;special <-

        $hGPOedit = WinWait("[CLASS:#32770]", "", 1)

        ;Retrieve the window text of the active window.
        Local $sText = WinGetText($hGPOedit)
        ;ConsoleWrite($sText & @CRLF)
        If StringLeft($sText, 22) = "Local Security Setting" Then  ; * <- if "Local Security Setting"
            ConsoleWrite("> $hGPOedit=special <" & @CRLF)
            $Txt &= "> $hGPOedit=special <" & @CRLF
            Switch $iSetting
                Case 0 ;Disabled
                    ControlSend($hGPOedit, "", "Button3", "s")
                    ConsoleWrite("-> Disabled" & @CRLF)
                    $Txt &= "-> Disabled" & @CRLF

                Case 1 ;Enabled
                    ControlSend($hGPOedit, "", "Button2", "e")
                    ConsoleWrite("-> Enabled" & @CRLF)
                    $Txt &= "-> Enabled" & @CRLF

                Case 3 ;find & exit
                    ConsoleWrite("-> find & exit" & @CRLF)
                    $Txt &= "-> find & exit" & @CRLF
                    GPOExit(1)

            EndSwitch
            ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}")
            Sleep(50)

            If WinExists("Confirm Setting Change") Then
                ControlSend("Confirm Setting Change", "", "Button1", "y") ; yes
            EndIf

        EndIf

    EndIf

    ;---------------------------------------------------------------

    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    ConsoleWrite("----------------------------------------" & @CRLF)
    $Txt &= "----------------------------------------" & @CRLF

    Return $ItemTxt[1]

EndFunc   ;==>_GroupPolicy
;-------------------------------------------------------------------------------
Func GPOExit($IgnoreGPO = 0)    ; $IgnoreGPO=0 exit ; $IgnoreGPO=1 exit Ignore GPO
;~  Exit  ; <-- ****************************************************
    If $IgnoreGPO = 0 Then
        ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")
        $hGPO = WinWait("Microsoft Management Console", "", 1)
        ControlSend($hGPO, "", "Static2", "{N}")
    EndIf

    _FileWriteLog(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".log", $Txt)
    Exit

EndFunc   ;==>GPOExit
;-------------------------------------------------------------------------------
Func _SetFile($sFile, $sData, $iFormat = 266) ; FileWrite Alternative
    Local $hFileOpen = FileOpen($sFile, $iFormat)
    If $hFileOpen = -1 Then
        Return SetError(1, 0, "")
    EndIf
    Local $msg = FileWrite($hFileOpen, $sData)
    FileClose($hFileOpen)
    Return $msg
EndFunc   ;==>_SetFile
;----------------------------------------------------------------------------------------
Func ReadIni($MyIni)  ; Ini.File switch
    ConsoleWrite("Ini.File:'" & $MyIni & "'" & @CRLF)
    $Txt &= "Ini.File:'" & $MyIni & "'" & @CRLF

    Local $iniFileExists = FileExists($MyIni)
    If Not $iniFileExists Then
        ConsoleWrite("not found the ini file:'" & $MyIni & "'" & @CRLF)
        $Txt &= "not found the ini file:'" & $MyIni & "'" & @CRLF
        GPOExit()
    EndIf

    ; Read the INI section names. This will return a 1 dimensional array.
    Local $aArray = IniReadSectionNames($MyIni)

    ; Check if an error occurred.
    If Not @error Then
        Local $sPolicyPath, $sPolicyItem, $iSetting, $sOption, $sReturn
        ; Enumerate through the array to the section names.
        For $i = 1 To $aArray[0]
            ;delete the return value
            IniWrite($MyIni, $aArray[$i], "Return", "")
            
            $sPolicyPath = IniRead($MyIni, $aArray[$i], "PolicyPath", "default")
            $sPolicyItem = IniRead($MyIni, $aArray[$i], "PolicyItem", "default")
            $iSetting = IniRead($MyIni, $aArray[$i], "Setting", "default")
            $sOption = IniRead($MyIni, $aArray[$i], "Option", "")

            $sReturn = _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption)
            
            ;Write the return value
            IniWrite($MyIni, $aArray[$i], "Return", $sReturn)

        Next
    EndIf
    GPOExit()
EndFunc   ;==>ReadIni
;----------------------------------------------------------------------------------------

 

Example  set_00.ini

[step_101]
PolicyPath=\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge
PolicyItem=Allow Adobe Flash
Setting=1
Option=
Return=Enabled
[step_102]
PolicyPath=\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options
PolicyItem=Microsoft network client: Digitally sign communications (always)
Setting=1
Option=
Return=Enabled
[step_103]
PolicyPath=\Computer Configuration\Administrative Templates\Windows Components\Connect
PolicyItem=Require pin for pairing
Setting=1
Option=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
Return=Enabled

 

I succeeded in doing script for export. but about script change Disabled or enabled. it changes other settings sometimes and does not close GPO you can see in video what I can do?

Link to comment
Share on other sites

46 minutes ago, gal9 said:

it changes other settings sometimes and does not close GPO you can see in video

I saw the video, but I didn't understand, i need more details

When you run the >headles.exe  which parameters is using in?

eg

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
    $CmdLine[2] = "Allow Adobe Flash"
    $CmdLine[3] = 0
    $CmdLine[4] = "" ;optional
EndIf

console out:

$CmdLine[0]=4
$CmdLine[1]=\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge
$CmdLine[2]=Allow Adobe Flash
$CmdLine[3]=0
$CmdLine[4]=
$hGPO=0x0000000000A90C80
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Microsoft Edge
- $FindItem=8
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Not configured
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x0000000000470B48
> $hGPOedit=normal <
-> Disabled
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Disabled
$ItemTxt[2]=No
$ItemTxt[3]=
----------------------------------------

or   the last piece of _GroupPolicy3.log :)

2023-03-28 10:13:57 : ======================================================================================================
$CmdLine[0]=4
$CmdLine[1]=\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge
$CmdLine[2]=Allow Adobe Flash
$CmdLine[3]=0
$CmdLine[4]=
$hGPO=0x0000000000A90C80
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Microsoft Edge
- $FindItem=8
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Not configured
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x0000000000470B48
> $hGPOedit=normal <
-> Disabled
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Disabled
$ItemTxt[2]=No
$ItemTxt[3]=
----------------------------------------

 

I know that I know nothing

Link to comment
Share on other sites

1 hour ago, ioa747 said:

I saw the video, but I didn't understand, i need more details

When you run the >headles.exe  which parameters is using in?

eg

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
    $CmdLine[2] = "Allow Adobe Flash"
    $CmdLine[3] = 0
    $CmdLine[4] = "" ;optional
EndIf

console out:

$CmdLine[0]=4
$CmdLine[1]=\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge
$CmdLine[2]=Allow Adobe Flash
$CmdLine[3]=0
$CmdLine[4]=
$hGPO=0x0000000000A90C80
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Microsoft Edge
- $FindItem=8
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Not configured
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x0000000000470B48
> $hGPOedit=normal <
-> Disabled
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Disabled
$ItemTxt[2]=No
$ItemTxt[3]=
----------------------------------------

or   the last piece of _GroupPolicy3.log :)

2023-03-28 10:13:57 : ======================================================================================================
$CmdLine[0]=4
$CmdLine[1]=\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge
$CmdLine[2]=Allow Adobe Flash
$CmdLine[3]=0
$CmdLine[4]=
$hGPO=0x0000000000A90C80
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Microsoft Edge
- $FindItem=8
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Not configured
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x0000000000470B48
> $hGPOedit=normal <
-> Disabled
- $SelectedItem=8
$ItemTxt[0]=Allow Adobe Flash
$ItemTxt[1]=Disabled
$ItemTxt[2]=No
$ItemTxt[3]=
----------------------------------------

 

ok so first about export i want create new file for export get only path. I would appreciate it if you could help me with review.
The first time I call the export does not work the second time it works behaves very strange this is the code:
 

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit
;   $CmdLine[3] - $iSetting    - T0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey"
;==============================================================
; EXAMPLES:
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0                                                          ; * - Normal
; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 3   ; * - Special
; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f"       ; * - With Option
; Global $CmdLine[5] = [4, "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0]

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
EndIf

Exit

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath)
Local $sDirPath ="C:\share\GPO-Export\" & @YEAR & "-" &@MON& "-"  & @MDAY
Local $sFilepath = $sDirPath & "--" & @HOUR& "-"  & @MIN  & "-"& @SEC

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinWait("Local Group Policy Editor", '', 5)

    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")
    Sleep(50)

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("--- $sPolicyPath=" & $sPolicyPath & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""
    Sleep(50)

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
            Sleep(50)

        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
            Sleep(50)

        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next
    Sleep(50)

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")
    Sleep(50)


    ControlSend($hGPO, "", $hTreeView_1, "{ALT}{A}{L}")
        Sleep(50)

    ControlFocus($hGPO, "", "[TITLE:Export List]")
    Sleep(50)

    WinWait("[TITLE:Export List]")
    ControlSend("[TITLE:Export List]", "", "", "{TAB}")
        Sleep(3000)
    ControlSend("[TITLE:Export List]", "", "", "{down}{down}")
    ControlSend("[TITLE:Export List]", "", "", "{Enter}")
    Sleep(3000)

    ControlSend("[TITLE:Export List]", "", "", "{ALT down}{n}{ALT up}")
    ControlSend("[TITLE:Export List]", "", "", $sFilepath)
    ControlSend("[TITLE:Export List]", "", "", "{Enter}")



    ;---------------------------------------------------------------

    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)



;~  Exit  ; <-- ****************************************************

    Sleep(50)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    $hGPO = WinWait("Microsoft Management Console", "", 1)
    ControlSend($hGPO, "", "Static2", "{N}")


EndFunc   ;==>_GroupPolicy
;----------------------------------------------------------------------------------------

Second, regarding what you saw in the video, this code:
 

#RequireAdmin
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit
;   $CmdLine[3] - $iSetting    - T0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey"
;==============================================================
; EXAMPLES:
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0                                                          ; * - Normal
; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 3   ; * - Special
; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f"       ; * - With Option
; Global $CmdLine[5] = [4, "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0]

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Connect"
    $CmdLine[2] = "Require pin for pairing"
    $CmdLine[3] = 1
    $CmdLine[4] = "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" ;optional
EndIf

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
EndIf

Exit

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "")

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinWait("Local Group Policy Editor", '', 5)

    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("--- $sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("--- $sPolicyItem=" & $sPolicyItem & @CRLF)
    ConsoleWrite("--- $iSetting=" & $iSetting & @CRLF)
    ConsoleWrite("--- $sOption=" & $sOption & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;find the item
    Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(500)
    ConsoleWrite("- $FindItem=" & $FindItem & @CRLF)

    ;If not found then Return Error
    If $FindItem = -1 Then
        ConsoleWrite("not found the entry:'" & $sPolicyItem & "'" & @CRLF)
        Return SetError(1, 0, "")
    EndIf

    ;select the found item
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)
    Sleep(50)

    ;snap Selected Item
    Local $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)

    Local $ItemTxt[4]
    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
    Next
        Sleep(50)
    ;and send enter to open it
    ControlSend($hGPO, '', $hListView, '{ENTER}')
        Sleep(50)
    ;---------------------------------------------------------------

    Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]", "", 1)
    ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)
        Sleep(50)
    If WinExists($hGPOedit) Then ; normal <-
        ConsoleWrite("> $hGPOedit=normal <" & @CRLF)
        Switch $iSetting
            Case 0 ;Disabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
                ConsoleWrite("-> Disabled" & @CRLF)

            Case 1 ;Enabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
                ConsoleWrite("-> Enabled" & @CRLF)

                If StringLen($sOption) > 0 Then
                    ConsoleWrite("- $sOption=" & $sOption & @CRLF)
                    Local $aOpt = StringSplit($sOption, ";", 1)
                    ControlSend($hGPOedit, "", $aOpt[1], $aOpt[2])
                EndIf

            Case 2 ;Configured
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c")
                ConsoleWrite("-> Configured" & @CRLF)

            Case 3 ;find & exit
                ConsoleWrite("-> find & exit" & @CRLF)
                Exit

        EndSwitch

        ;Apply
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "a")

        ;Enter
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "{ENTER}")

    Else ;special <-

        $hGPOedit = WinWait("[CLASS:#32770]", "", 1)

        ;Retrieve the window text of the active window.
        Local $sText = WinGetText($hGPOedit)
        ;ConsoleWrite($sText & @CRLF)
        If StringLeft($sText, 22) = "Local Security Setting" Then  ; * <- if "Local Security Setting"
            ConsoleWrite("> $hGPOedit=special <" & @CRLF)
            Switch $iSetting
                Case 0 ;Disabled
                    ControlSend($hGPOedit, "", "Button3", "s")
                    ConsoleWrite("-> Disabled" & @CRLF)

                Case 1 ;Enabled
                    ControlSend($hGPOedit, "", "Button2", "e")
                    ConsoleWrite("-> Enabled" & @CRLF)

                Case 3 ;find & exit
                    ConsoleWrite("-> find & exit" & @CRLF)
                    Exit

            EndSwitch
            ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}")
            Sleep(50)

            If WinExists("Confirm Setting Change") Then
                ControlSend("Confirm Setting Change", "", "Button1", "y") ; yes
            EndIf

        EndIf

    EndIf

    ;---------------------------------------------------------------
    Sleep(50)
    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)
    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
    Next

;~  Exit  ; <-- ****************************************************

    Sleep(50)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")
    Sleep(50)
    $hGPO = WinWait("Microsoft Management Console", "", 1)
    ControlSend($hGPO, "", "Static2", "{N}")

    Return $sPolicyItem

EndFunc   ;==>_GroupPolicy
;----------------------------------------------------------------------------------------

I don't know why the code runs twice 

Link to comment
Share on other sites

24 minutes ago, gal9 said:

ok so first about export i want create new file for export get only path.

what do you want to export?, for what purpose?

that doesn't make sense because you already know that

eg here

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
    $CmdLine[2] = "Allow Adobe Flash"
    $CmdLine[3] = 4
    $CmdLine[4] = "" ;optional
EndIf

as long as you give the path to the parameter [1] What return it to you?

"\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"

 

I know that I know nothing

Link to comment
Share on other sites

could export list from "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"

if that's what you want

Setting State   Comment
Allow Address bar drop-down list suggestions    Not configured  No
Configure Autofill  Not configured  No
Allow Microsoft Compatibility List  Not configured  No
Allow clearing browsing data on exit    Not configured  No
Allow configuration updates for the Books Library   Not configured  No
Allow Developer Tools   Not configured  No
Configure Do Not Track  Not configured  No
Allow Extensions    Not configured  No
Allow Adobe Flash   Not configured  No
Configure the Adobe Flash Click-to-Run setting  Not configured  No
Allow FullScreen Mode   Not configured  No
Allow InPrivate browsing    Not configured  No
For PDF files that have both landscape and portrait pages, print each in its own orientation.   Not configured  No
Configure Password Manager  Not configured  No
Configure Pop-up Blocker    Not configured  No
Allow Microsoft Edge to pre-launch at Windows startup, when the system is idle, and each time Microsoft Edge is closed  Not configured  No
Allow printing  Not configured  No
Allow Saving History    Not configured  No
Allow search engine customization   Not configured  No
Configure search suggestions in Address bar Not configured  No
Allow Sideloading of extension  Not configured  No
Configure Windows Defender SmartScreen  Not configured  No
Allow Microsoft Edge to start and load the Start and New Tab page at Windows startup and each time Microsoft Edge is closed Not configured  No
Allow web content on New Tab page   Not configured  No
Always show the Books Library in Microsoft Edge Not configured  No
Configure additional search engines Not configured  No
Configure Favorites Bar Not configured  No
Configure Home Button   Not configured  No
Configure kiosk mode    Not configured  No
Configure kiosk reset after idle timeout    Not configured  No
Configure Open Microsoft Edge With  Not configured  No
Provision Favorites Not configured  No
Configure cookies   Not configured  No
Disable lockdown of Start pages Not configured  No
Allow extended telemetry for the Books tab  Not configured  No
Configure the Enterprise Mode Site List Not configured  No
Configure Favorites Not configured  No
Prevent using Localhost IP address for WebRTC   Not configured  No
Configure Start pages   Not configured  No
Prevent changes to Favorites on Microsoft Edge  Not configured  No
Prevent access to the about:flags page in Microsoft Edge    Not configured  No
Prevent certificate error overrides Not configured  No
Prevent the First Run webpage from opening on Microsoft Edge    Not configured  No
Prevent Microsoft Edge from gathering Live Tile information when pinning a site to Start    Not configured  No
Prevent bypassing Windows Defender SmartScreen prompts for sites    Not configured  No
Prevent bypassing Windows Defender SmartScreen prompts for files    Not configured  No
Prevent turning off required extensions Not configured  No
Send all intranet sites to Internet Explorer 11 Not configured  No
Set default search engine   Not configured  No
Set Home Button URL Not configured  No
Set New Tab page URL    Not configured  No
Show message when opening sites in Internet Explorer    Not configured  No
Suppress the display of Edge Deprecation Notification   Not configured  No
Keep favorites in sync between Internet Explorer and Microsoft Edge Not configured  No
Unlock Home Button  Not configured  No
Allow a shared Books folder Not configured  No

 

I know that I know nothing

Link to comment
Share on other sites

15 minutes ago, ioa747 said:

what do you want to export?, for what purpose?

that doesn't make sense because you already know that

eg here

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
    $CmdLine[2] = "Allow Adobe Flash"
    $CmdLine[3] = 4
    $CmdLine[4] = "" ;optional
EndIf

as long as you give the path to the parameter [1] What return it to you?

"\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"

 

About export I want cate exe If I doesn't send pamter so by default it is export the "\Computer Configuration\Administrative Templates\All Settings" to csv  with a time stamp.

And about the first script You have something new? Why it work srange 

Edited by gal9
Link to comment
Share on other sites

1 hour ago, ioa747 said:

?? I do not understand

just export the "\Computer Configuration\Administrative Templates\All Settings" to csv  with a time stamp. ?

Sorry 

I want create a new script for export not same code Because it is all in one script it is very long.

So now I have two problems 

Once my export script The first time I call the export does not work the second time it works behaves very strange I sent the code before...

another problem the code of _GroupPolicy3 you can see in video, Changes once incorrect setting the second time correct setting.

Edited by gal9
Link to comment
Share on other sites

CSV.File switch

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"  ;$sPolicyPath to export
    $CmdLine[2] = "CSV.File" ; CSV.File switch
    $CmdLine[3] = 0
    $CmdLine[4] = @ScriptDir & "\GPO-Export\" & @YEAR & "-" & @MON & "-" & @MDAY & "--" & @HOUR & "-" & @MIN & "-" & @SEC ; Path to save the CSV.File
EndIf

in this case the folder  GPO-Export  must exist

_GroupPolicy3 .au3

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=0.0.0.16
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=_GroupPolicy3.au3
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate | if INI.File switch then the ini file path
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit | INI.File switch | CSV.File switch
;   $CmdLine[3] - $iSetting    - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey" | if CSV.File switch then the CSV file path
;==============================================================

;~ If Not $CmdLine[0] Then  ;Example *** - Normal ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"  ; $sPolicyPath
;~  $CmdLine[2] = "Allow Adobe Flash"  ; $sPolicyItem
;~  $CmdLine[3] = 2  ; $iSetting - 0=Disabled, 1=Enabled, 2=Configured
;~  $CmdLine[4] = "" ;nothing
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - Special ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options"
;~  $CmdLine[2] = "Microsoft network client: Digitally sign communications (always)"
;~  $CmdLine[3] = 1  ;1=Enabled
;~  $CmdLine[4] = "" ;nothing
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - With Option ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Connect"
;~  $CmdLine[2] = "Require pin for pairing"
;~  $CmdLine[3] = 1  ;1=Enabled
;~  $CmdLine[4] = "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" ;send f to control
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - 3=find & exit ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
;~  $CmdLine[2] = "Allow Adobe Flash"
;~  $CmdLine[3] = 3  ;3=find & exit
;~  $CmdLine[4] = ""  ; not using
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - 4=Export.value ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
;~  $CmdLine[2] = "Allow Adobe Flash"
;~  $CmdLine[3] = 4  ;4=Export.value to @ScriptName.value file
;~  $CmdLine[4] = ""  ; not using
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - INI.File switch  ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = @ScriptDir & "\set_00.ini"  ; the ini file path
;~  $CmdLine[2] = "Ini.File"  ; * - INI.File switch
;~  $CmdLine[3] = 0  ;
;~  $CmdLine[4] = "" ;optional
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - CSV.File switch  ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"  ;$sPolicyPath to export
;~  $CmdLine[2] = "CSV.File" ; CSV.File switch
;~  $CmdLine[3] = 0
;~  $CmdLine[4] = @ScriptDir & "\GPO-Export\" & @YEAR & "-" & @MON & "-" & @MDAY & "--" & @HOUR & "-" & @MIN & "-" & @SEC ; Path to save the CSV.File
;~ EndIf

If Not $CmdLine[0] Then 
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt ; not using
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"  ;$sPolicyPath to export
    $CmdLine[2] = "CSV.File" ; CSV.File switch
    $CmdLine[3] = 0
    $CmdLine[4] = @ScriptDir & "\GPO-Export\" & @YEAR & "-" & @MON & "-" & @MDAY & "--" & @HOUR & "-" & @MIN & "-" & @SEC ; Path to save the CSV.File
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("==================================")
ConsoleWrite("==================================")
ConsoleWrite("==================================" & @CRLF)

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)
ConsoleWrite("$CmdLine[1]=" & $CmdLine[1] & @CRLF)
ConsoleWrite("$CmdLine[2]=" & $CmdLine[2] & @CRLF)
ConsoleWrite("$CmdLine[3]=" & $CmdLine[3] & @CRLF)
ConsoleWrite("$CmdLine[4]=" & $CmdLine[4] & @CRLF)

Global $Txt = "=================================="
$Txt &= "=================================="
$Txt &= "==================================" & @CRLF

$Txt &= "$CmdLine[0]=" & $CmdLine[0] & @CRLF
$Txt &= "$CmdLine[1]=" & $CmdLine[1] & @CRLF
$Txt &= "$CmdLine[2]=" & $CmdLine[2] & @CRLF
$Txt &= "$CmdLine[3]=" & $CmdLine[3] & @CRLF
$Txt &= "$CmdLine[4]=" & $CmdLine[4] & @CRLF


If Not WinExists("Local Group Policy Editor") Then
    Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
EndIf

;Retrieves the 'Local Group Policy Editor' window handle
Global $hGPO = WinWait("Local Group Policy Editor", '', 5)

ConsoleWrite("- $hGPO=" & $hGPO & @CRLF)
$Txt &= "- $hGPO=" & $hGPO & @CRLF

;Retrieves the SysTreeView321 control handle
Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

ConsoleWrite("- $hTreeView_1=" & $hTreeView_1 & @CRLF)
$Txt &= "- $hTreeView_1=" & $hTreeView_1 & @CRLF

;look for $sPolicyItem switch
Switch $CmdLine[2]

    Case "INI.File"  ;INI.File switch
        ReadIni($CmdLine[1])

    Case "CSV.File"  ;CSV.File switch
        ExportCSV($CmdLine[4])

    Case Else
        ;continued

EndSwitch

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
    $Txt &= "! incorect number of parameters:" & $CmdLine[0]
    GPOExit()
EndIf

GPOExit()

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        $Txt &= "$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ConsoleWrite("- $hListView=" & $hListView & @CRLF)
    $Txt &= "- $hListView=" & $hListView & @CRLF

    ;find the item
    Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(1000)
    ConsoleWrite("- $FindItem=" & $FindItem & @CRLF)
    $Txt &= "- $FindItem=" & $FindItem & @CRLF

    ;If not found then Return Error
    If $FindItem = -1 Then
        ConsoleWrite("! not found the entry:'" & $sPolicyItem & "'" & @CRLF)
        $Txt &= "! not found the entry:'" & $sPolicyItem & "'" & @CRLF
        ;Return SetError(1, 0, "")
        GPOExit()
    EndIf

    ;select the found item
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)
    Sleep(50)

    ;snap Selected Item
    Local $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    Local $ItemTxt[4]
    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    ;check if $SelectedItem = $sPolicyItem
    If $ItemTxt[0] <> $sPolicyItem Then
        ConsoleWrite("! " & $sPolicyItem & " <> " & $SelectedItem & @CRLF)
        $Txt &= "! " & $sPolicyItem & " <> " & $SelectedItem & @CRLF
        GPOExit()
    EndIf

    ConsoleWrite("- " & $sPolicyItem & " = " & $ItemTxt[0] & @CRLF)
    $Txt &= "- " & $sPolicyItem & " = " & $ItemTxt[0] & @CRLF

    ;If $iSetting=4 => Export.value
    If $iSetting = 4 Then
        Local $sValue = ""
        ConsoleWrite("- $iSetting=Export.value" & @CRLF)
        $Txt &= "- $iSetting=Export.value" & @CRLF
        For $i = 0 To 3
            $sValue &= $ItemTxt[$i] & ", "
        Next
        ;$sValue = StringTrimRight($sValue, 2) & StringReplace(StringTrimRight($tmpPath, 1), "|", "\")
        $sValue = StringTrimRight($sValue, 2)
        _SetFile(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".value", $sValue)

        GPOExit()

    EndIf

    ;and send enter to open it
    ControlSend($hGPO, '', $hListView, '{ENTER}')

    ;---------------------------------------------------------------

    Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]", "", 3)
    ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)
    $Txt &= "- $hGPOedit=" & $hGPOedit & @CRLF

    If WinExists($hGPOedit) Then ; normal <-
        ConsoleWrite("> $hGPOedit=normal <" & @CRLF)
        $Txt &= "> $hGPOedit=normal <" & @CRLF
        Switch $iSetting
            Case 0 ;Disabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
                ConsoleWrite("-> Disabled" & @CRLF)
                $Txt &= "-> Disabled" & @CRLF

            Case 1 ;Enabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
                ConsoleWrite("-> Enabled" & @CRLF)
                $Txt &= "-> Enabled" & @CRLF

                If StringLen($sOption) > 0 Then
                    ConsoleWrite("- $sOption=" & $sOption & @CRLF)
                    $Txt &= "- $sOption=" & $sOption & @CRLF
                    Local $aOpt = StringSplit($sOption, ";", 1)
                    ControlSend($hGPOedit, "", $aOpt[1], $aOpt[2])
                EndIf

            Case 2 ;Configured
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c")
                ConsoleWrite("-> Configured" & @CRLF)
                $Txt &= "-> Configured" & @CRLF

            Case 3 ;find & exit
                ConsoleWrite("-> find & exit" & @CRLF)
                $Txt &= "-> find & exit" & @CRLF
                GPOExit(1)

        EndSwitch

        ;Apply
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "a")

        ;Enter
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "{ENTER}")

    Else ;special <-

        $hGPOedit = WinWait("[CLASS:#32770]", "", 3)
        ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)
        $Txt &= "- $hGPOedit=" & $hGPOedit & @CRLF

        ;Retrieve the window text of the active window.
        Local $sText = WinGetText($hGPOedit)
        ;ConsoleWrite($sText & @CRLF)
        If StringLeft($sText, 22) = "Local Security Setting" Then  ; * <- if "Local Security Setting"
            ConsoleWrite("> $hGPOedit=special <" & @CRLF)
            $Txt &= "> $hGPOedit=special <" & @CRLF
            Switch $iSetting
                Case 0 ;Disabled
                    ControlSend($hGPOedit, "", "Button3", "s")
                    ConsoleWrite("-> Disabled" & @CRLF)
                    $Txt &= "-> Disabled" & @CRLF

                Case 1 ;Enabled
                    ControlSend($hGPOedit, "", "Button2", "e")
                    ConsoleWrite("-> Enabled" & @CRLF)
                    $Txt &= "-> Enabled" & @CRLF

                Case 3 ;find & exit
                    ConsoleWrite("-> find & exit" & @CRLF)
                    $Txt &= "-> find & exit" & @CRLF
                    GPOExit(1)

            EndSwitch
            ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}")
            Sleep(50)

            If WinExists("Confirm Setting Change") Then
                ControlSend("Confirm Setting Change", "", "Button1", "y") ; yes
            EndIf

        EndIf

    EndIf

    ;---------------------------------------------------------------

    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    Return $ItemTxt[1]

EndFunc   ;==>_GroupPolicy
;-------------------------------------------------------------------------------
Func GPOExit($IgnoreGPO = 0)  ; $IgnoreGPO=0 exit ; $IgnoreGPO=1 exit Ignore GPO
;~  Exit  ; <-- ****************************************************

    If $IgnoreGPO = 0 Then
        ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")
        $hGPO = WinWait("Microsoft Management Console", "", 2)
        ConsoleWrite("- exit $hGPO=" & $hGPO & @CRLF)
        $Txt &= "- exit $hGPO=" & $hGPO & @CRLF
        ControlSend($hGPO, "", "Static2", "{N}")
    EndIf

    _FileWriteLog(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".log", $Txt)
    Exit

EndFunc   ;==>GPOExit
;-------------------------------------------------------------------------------
Func _SetFile($sFile, $sData, $iFormat = 266)  ; FileWrite Alternative
    Local $hFileOpen = FileOpen($sFile, $iFormat)
    If $hFileOpen = -1 Then
        Return SetError(1, 0, "")
    EndIf
    Local $msg = FileWrite($hFileOpen, $sData)
    FileClose($hFileOpen)
    Return $msg
EndFunc   ;==>_SetFile
;----------------------------------------------------------------------------------------
Func ReadIni($MyIni)  ; INI.File switch

    ConsoleWrite("- INI.File switch" & @CRLF)
    $Txt &= "- INI.File switch" & @CRLF
    ConsoleWrite("- File:'" & $MyIni & "'" & @CRLF)
    $Txt &= "- File:'" & $MyIni & "'" & @CRLF

    Local $iniFileExists = FileExists($MyIni)
    If Not $iniFileExists Then
        ConsoleWrite("! not found the ini file:'" & $MyIni & "'" & @CRLF)
        $Txt &= "! not found the ini file:'" & $MyIni & "'" & @CRLF
        GPOExit()
    EndIf

    ; Read the INI section names. This will return a 1 dimensional array.
    Local $aArray = IniReadSectionNames($MyIni)

    ; Check if an error occurred.
    If Not @error Then
        Local $sPolicyPath, $sPolicyItem, $iSetting, $sOption, $sReturn

        ConsoleWrite("----------------------------------------" & @CRLF)
        $Txt &= "----------------------------------------" & @CRLF

        ; Enumerate through the array to the section names.
        For $i = 1 To $aArray[0]
            ConsoleWrite("- [" & $aArray[$i] & "]" & @CRLF)
            $Txt &= "- [" & $aArray[$i] & "]" & @CRLF

            ;delete the return value
            IniWrite($MyIni, $aArray[$i], "Return", "")

            $sPolicyPath = IniRead($MyIni, $aArray[$i], "PolicyPath", "default")
            $sPolicyItem = IniRead($MyIni, $aArray[$i], "PolicyItem", "default")
            $iSetting = IniRead($MyIni, $aArray[$i], "Setting", "default")
            $sOption = IniRead($MyIni, $aArray[$i], "Option", "")

            $sReturn = _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption)

            ;Write the return value
            IniWrite($MyIni, $aArray[$i], "Return", $sReturn)

            ConsoleWrite("----------------------------------------" & @CRLF)
            $Txt &= "----------------------------------------" & @CRLF

        Next
    EndIf
    GPOExit()
EndFunc   ;==>ReadIni
;----------------------------------------------------------------------------------------
Func ExportCSV($MyCsv)  ; CSV.File switch

    ConsoleWrite("- CSV.File switch" & @CRLF)
    $Txt &= "- CSV.File switch" & @CRLF

    Local $sPolicyPath = "Local Computer Policy" & $CmdLine[1]

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        $Txt &= "$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    Sleep(100)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT}{A}{L}")

    WinWait("Export List", "", 2)

    ControlSend("Export List", "", "Edit1", @TAB)
    Sleep(50)

;~  Local $ControlClassNameNN = ControlGetFocus("Export List")              ;*
;~  ConsoleWrite("- $ControlClassNameNN=" & $ControlClassNameNN & @CRLF)    ;*
;~  $Txt &= "- $ControlClassNameNN=" & $ControlClassNameNN & @CRLF          ;*

    Local $hControl = ControlGetHandle("Export List", '', "ComboBox3")
    ConsoleWrite("- $hControl=" & $hControl & @CRLF)
    $Txt &= "- $hControl=" & $hControl & @CRLF

    ControlSend("Export List", "", $hControl, "{down}{down}")
    Sleep(50)

    ControlSend("Export List", "", $hControl, "{Enter}")
    Sleep(50)

    ControlSetText("Export List", "", "Edit1", $MyCsv)
    Sleep(50)

    ControlSend("Export List", "", "Edit1", "{Enter}")
    Sleep(50)

    Local $CsvFileExists = FileExists($MyCsv & ".csv")
    If $CsvFileExists Then
        ConsoleWrite("- Exists the Csv file:'" & $MyCsv & ".csv'" & @CRLF)
        $Txt &= "- Exists the Csv file:'" & $MyCsv & ".csv'" & @CRLF
    Else
        ConsoleWrite("! not found the Csv file:'" & $MyCsv & ".csv'" & @CRLF)
        $Txt &= "! not found the Csv file:'" & $MyCsv & ".csv'" & @CRLF
    EndIf

    GPOExit()

EndFunc   ;==>ExportCSV

 

Edited by ioa747
remove ControlGetFocus

I know that I know nothing

Link to comment
Share on other sites

15 hours ago, ioa747 said:

CSV.File switch

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"  ;$sPolicyPath to export
    $CmdLine[2] = "CSV.File" ; CSV.File switch
    $CmdLine[3] = 0
    $CmdLine[4] = @ScriptDir & "\GPO-Export\" & @YEAR & "-" & @MON & "-" & @MDAY & "--" & @HOUR & "-" & @MIN & "-" & @SEC ; Path to save the CSV.File
EndIf

in this case the folder  GPO-Export  must exist

_GroupPolicy3 .au3

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=0.0.0.16
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=_GroupPolicy3.au3
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate | if INI.File switch then the ini file path
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit | INI.File switch | CSV.File switch
;   $CmdLine[3] - $iSetting    - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey" | if CSV.File switch then the CSV file path
;==============================================================

;~ If Not $CmdLine[0] Then  ;Example *** - Normal ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"  ; $sPolicyPath
;~  $CmdLine[2] = "Allow Adobe Flash"  ; $sPolicyItem
;~  $CmdLine[3] = 2  ; $iSetting - 0=Disabled, 1=Enabled, 2=Configured
;~  $CmdLine[4] = "" ;nothing
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - Special ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options"
;~  $CmdLine[2] = "Microsoft network client: Digitally sign communications (always)"
;~  $CmdLine[3] = 1  ;1=Enabled
;~  $CmdLine[4] = "" ;nothing
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - With Option ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Connect"
;~  $CmdLine[2] = "Require pin for pairing"
;~  $CmdLine[3] = 1  ;1=Enabled
;~  $CmdLine[4] = "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" ;send f to control
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - 3=find & exit ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
;~  $CmdLine[2] = "Allow Adobe Flash"
;~  $CmdLine[3] = 3  ;3=find & exit
;~  $CmdLine[4] = ""  ; not using
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - 4=Export.value ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge"
;~  $CmdLine[2] = "Allow Adobe Flash"
;~  $CmdLine[3] = 4  ;4=Export.value to @ScriptName.value file
;~  $CmdLine[4] = ""  ; not using
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - INI.File switch  ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = @ScriptDir & "\set_00.ini"  ; the ini file path
;~  $CmdLine[2] = "Ini.File"  ; * - INI.File switch
;~  $CmdLine[3] = 0  ;
;~  $CmdLine[4] = "" ;optional
;~ EndIf

;~ If Not $CmdLine[0] Then  ;Example *** - CSV.File switch  ***
;~  Global $CmdLine[5]
;~  $CmdLine[0] = 4 ;cnt ; not using
;~  $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"  ;$sPolicyPath to export
;~  $CmdLine[2] = "CSV.File" ; CSV.File switch
;~  $CmdLine[3] = 0
;~  $CmdLine[4] = @ScriptDir & "\GPO-Export\" & @YEAR & "-" & @MON & "-" & @MDAY & "--" & @HOUR & "-" & @MIN & "-" & @SEC ; Path to save the CSV.File
;~ EndIf

If Not $CmdLine[0] Then 
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt ; not using
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\All Settings"  ;$sPolicyPath to export
    $CmdLine[2] = "CSV.File" ; CSV.File switch
    $CmdLine[3] = 0
    $CmdLine[4] = @ScriptDir & "\GPO-Export\" & @YEAR & "-" & @MON & "-" & @MDAY & "--" & @HOUR & "-" & @MIN & "-" & @SEC ; Path to save the CSV.File
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("==================================")
ConsoleWrite("==================================")
ConsoleWrite("==================================" & @CRLF)

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)
ConsoleWrite("$CmdLine[1]=" & $CmdLine[1] & @CRLF)
ConsoleWrite("$CmdLine[2]=" & $CmdLine[2] & @CRLF)
ConsoleWrite("$CmdLine[3]=" & $CmdLine[3] & @CRLF)
ConsoleWrite("$CmdLine[4]=" & $CmdLine[4] & @CRLF)

Global $Txt = "=================================="
$Txt &= "=================================="
$Txt &= "==================================" & @CRLF

$Txt &= "$CmdLine[0]=" & $CmdLine[0] & @CRLF
$Txt &= "$CmdLine[1]=" & $CmdLine[1] & @CRLF
$Txt &= "$CmdLine[2]=" & $CmdLine[2] & @CRLF
$Txt &= "$CmdLine[3]=" & $CmdLine[3] & @CRLF
$Txt &= "$CmdLine[4]=" & $CmdLine[4] & @CRLF


If Not WinExists("Local Group Policy Editor") Then
    Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
EndIf

;Retrieves the 'Local Group Policy Editor' window handle
Global $hGPO = WinWait("Local Group Policy Editor", '', 5)

ConsoleWrite("- $hGPO=" & $hGPO & @CRLF)
$Txt &= "- $hGPO=" & $hGPO & @CRLF

;Retrieves the SysTreeView321 control handle
Global $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

ConsoleWrite("- $hTreeView_1=" & $hTreeView_1 & @CRLF)
$Txt &= "- $hTreeView_1=" & $hTreeView_1 & @CRLF

;look for $sPolicyItem switch
Switch $CmdLine[2]

    Case "INI.File"  ;INI.File switch
        ReadIni($CmdLine[1])

    Case "CSV.File"  ;CSV.File switch
        ExportCSV($CmdLine[4])

    Case Else
        ;continued

EndSwitch

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
    $Txt &= "! incorect number of parameters:" & $CmdLine[0]
    GPOExit()
EndIf

GPOExit()

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit, 4=Export.value
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        $Txt &= "$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ConsoleWrite("- $hListView=" & $hListView & @CRLF)
    $Txt &= "- $hListView=" & $hListView & @CRLF

    ;find the item
    Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(1000)
    ConsoleWrite("- $FindItem=" & $FindItem & @CRLF)
    $Txt &= "- $FindItem=" & $FindItem & @CRLF

    ;If not found then Return Error
    If $FindItem = -1 Then
        ConsoleWrite("! not found the entry:'" & $sPolicyItem & "'" & @CRLF)
        $Txt &= "! not found the entry:'" & $sPolicyItem & "'" & @CRLF
        ;Return SetError(1, 0, "")
        GPOExit()
    EndIf

    ;select the found item
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)
    Sleep(50)

    ;snap Selected Item
    Local $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    Local $ItemTxt[4]
    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", $SelectedItem, $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    ;check if $SelectedItem = $sPolicyItem
    If $ItemTxt[0] <> $sPolicyItem Then
        ConsoleWrite("! " & $sPolicyItem & " <> " & $SelectedItem & @CRLF)
        $Txt &= "! " & $sPolicyItem & " <> " & $SelectedItem & @CRLF
        GPOExit()
    EndIf

    ConsoleWrite("- " & $sPolicyItem & " = " & $ItemTxt[0] & @CRLF)
    $Txt &= "- " & $sPolicyItem & " = " & $ItemTxt[0] & @CRLF

    ;If $iSetting=4 => Export.value
    If $iSetting = 4 Then
        Local $sValue = ""
        ConsoleWrite("- $iSetting=Export.value" & @CRLF)
        $Txt &= "- $iSetting=Export.value" & @CRLF
        For $i = 0 To 3
            $sValue &= $ItemTxt[$i] & ", "
        Next
        ;$sValue = StringTrimRight($sValue, 2) & StringReplace(StringTrimRight($tmpPath, 1), "|", "\")
        $sValue = StringTrimRight($sValue, 2)
        _SetFile(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".value", $sValue)

        GPOExit()

    EndIf

    ;and send enter to open it
    ControlSend($hGPO, '', $hListView, '{ENTER}')

    ;---------------------------------------------------------------

    Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]", "", 3)
    ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)
    $Txt &= "- $hGPOedit=" & $hGPOedit & @CRLF

    If WinExists($hGPOedit) Then ; normal <-
        ConsoleWrite("> $hGPOedit=normal <" & @CRLF)
        $Txt &= "> $hGPOedit=normal <" & @CRLF
        Switch $iSetting
            Case 0 ;Disabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
                ConsoleWrite("-> Disabled" & @CRLF)
                $Txt &= "-> Disabled" & @CRLF

            Case 1 ;Enabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
                ConsoleWrite("-> Enabled" & @CRLF)
                $Txt &= "-> Enabled" & @CRLF

                If StringLen($sOption) > 0 Then
                    ConsoleWrite("- $sOption=" & $sOption & @CRLF)
                    $Txt &= "- $sOption=" & $sOption & @CRLF
                    Local $aOpt = StringSplit($sOption, ";", 1)
                    ControlSend($hGPOedit, "", $aOpt[1], $aOpt[2])
                EndIf

            Case 2 ;Configured
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c")
                ConsoleWrite("-> Configured" & @CRLF)
                $Txt &= "-> Configured" & @CRLF

            Case 3 ;find & exit
                ConsoleWrite("-> find & exit" & @CRLF)
                $Txt &= "-> find & exit" & @CRLF
                GPOExit(1)

        EndSwitch

        ;Apply
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "a")

        ;Enter
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "{ENTER}")

    Else ;special <-

        $hGPOedit = WinWait("[CLASS:#32770]", "", 3)
        ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)
        $Txt &= "- $hGPOedit=" & $hGPOedit & @CRLF

        ;Retrieve the window text of the active window.
        Local $sText = WinGetText($hGPOedit)
        ;ConsoleWrite($sText & @CRLF)
        If StringLeft($sText, 22) = "Local Security Setting" Then  ; * <- if "Local Security Setting"
            ConsoleWrite("> $hGPOedit=special <" & @CRLF)
            $Txt &= "> $hGPOedit=special <" & @CRLF
            Switch $iSetting
                Case 0 ;Disabled
                    ControlSend($hGPOedit, "", "Button3", "s")
                    ConsoleWrite("-> Disabled" & @CRLF)
                    $Txt &= "-> Disabled" & @CRLF

                Case 1 ;Enabled
                    ControlSend($hGPOedit, "", "Button2", "e")
                    ConsoleWrite("-> Enabled" & @CRLF)
                    $Txt &= "-> Enabled" & @CRLF

                Case 3 ;find & exit
                    ConsoleWrite("-> find & exit" & @CRLF)
                    $Txt &= "-> find & exit" & @CRLF
                    GPOExit(1)

            EndSwitch
            ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}")
            Sleep(50)

            If WinExists("Confirm Setting Change") Then
                ControlSend("Confirm Setting Change", "", "Button1", "y") ; yes
            EndIf

        EndIf

    EndIf

    ;---------------------------------------------------------------

    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    $Txt &= "- $SelectedItem=" & $SelectedItem & @CRLF
    Sleep(50)

    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
        $Txt &= "$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF
    Next

    Return $ItemTxt[1]

EndFunc   ;==>_GroupPolicy
;-------------------------------------------------------------------------------
Func GPOExit($IgnoreGPO = 0)  ; $IgnoreGPO=0 exit ; $IgnoreGPO=1 exit Ignore GPO
;~  Exit  ; <-- ****************************************************

    If $IgnoreGPO = 0 Then
        ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")
        $hGPO = WinWait("Microsoft Management Console", "", 2)
        ConsoleWrite("- exit $hGPO=" & $hGPO & @CRLF)
        $Txt &= "- exit $hGPO=" & $hGPO & @CRLF
        ControlSend($hGPO, "", "Static2", "{N}")
    EndIf

    _FileWriteLog(@ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".log", $Txt)
    Exit

EndFunc   ;==>GPOExit
;-------------------------------------------------------------------------------
Func _SetFile($sFile, $sData, $iFormat = 266)  ; FileWrite Alternative
    Local $hFileOpen = FileOpen($sFile, $iFormat)
    If $hFileOpen = -1 Then
        Return SetError(1, 0, "")
    EndIf
    Local $msg = FileWrite($hFileOpen, $sData)
    FileClose($hFileOpen)
    Return $msg
EndFunc   ;==>_SetFile
;----------------------------------------------------------------------------------------
Func ReadIni($MyIni)  ; INI.File switch

    ConsoleWrite("- INI.File switch" & @CRLF)
    $Txt &= "- INI.File switch" & @CRLF
    ConsoleWrite("- File:'" & $MyIni & "'" & @CRLF)
    $Txt &= "- File:'" & $MyIni & "'" & @CRLF

    Local $iniFileExists = FileExists($MyIni)
    If Not $iniFileExists Then
        ConsoleWrite("! not found the ini file:'" & $MyIni & "'" & @CRLF)
        $Txt &= "! not found the ini file:'" & $MyIni & "'" & @CRLF
        GPOExit()
    EndIf

    ; Read the INI section names. This will return a 1 dimensional array.
    Local $aArray = IniReadSectionNames($MyIni)

    ; Check if an error occurred.
    If Not @error Then
        Local $sPolicyPath, $sPolicyItem, $iSetting, $sOption, $sReturn

        ConsoleWrite("----------------------------------------" & @CRLF)
        $Txt &= "----------------------------------------" & @CRLF

        ; Enumerate through the array to the section names.
        For $i = 1 To $aArray[0]
            ConsoleWrite("- [" & $aArray[$i] & "]" & @CRLF)
            $Txt &= "- [" & $aArray[$i] & "]" & @CRLF

            ;delete the return value
            IniWrite($MyIni, $aArray[$i], "Return", "")

            $sPolicyPath = IniRead($MyIni, $aArray[$i], "PolicyPath", "default")
            $sPolicyItem = IniRead($MyIni, $aArray[$i], "PolicyItem", "default")
            $iSetting = IniRead($MyIni, $aArray[$i], "Setting", "default")
            $sOption = IniRead($MyIni, $aArray[$i], "Option", "")

            $sReturn = _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption)

            ;Write the return value
            IniWrite($MyIni, $aArray[$i], "Return", $sReturn)

            ConsoleWrite("----------------------------------------" & @CRLF)
            $Txt &= "----------------------------------------" & @CRLF

        Next
    EndIf
    GPOExit()
EndFunc   ;==>ReadIni
;----------------------------------------------------------------------------------------
Func ExportCSV($MyCsv)  ; CSV.File switch

    ConsoleWrite("- CSV.File switch" & @CRLF)
    $Txt &= "- CSV.File switch" & @CRLF

    Local $sPolicyPath = "Local Computer Policy" & $CmdLine[1]

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        $Txt &= "$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    Sleep(100)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT}{A}{L}")

    WinWait("Export List", "", 2)

    ControlSend("Export List", "", "Edit1", @TAB)
    Sleep(50)

;~  Local $ControlClassNameNN = ControlGetFocus("Export List")              ;*
;~  ConsoleWrite("- $ControlClassNameNN=" & $ControlClassNameNN & @CRLF)    ;*
;~  $Txt &= "- $ControlClassNameNN=" & $ControlClassNameNN & @CRLF          ;*

    Local $hControl = ControlGetHandle("Export List", '', "ComboBox3")
    ConsoleWrite("- $hControl=" & $hControl & @CRLF)
    $Txt &= "- $hControl=" & $hControl & @CRLF

    ControlSend("Export List", "", $hControl, "{down}{down}")
    Sleep(50)

    ControlSend("Export List", "", $hControl, "{Enter}")
    Sleep(50)

    ControlSetText("Export List", "", "Edit1", $MyCsv)
    Sleep(50)

    ControlSend("Export List", "", "Edit1", "{Enter}")
    Sleep(50)

    Local $CsvFileExists = FileExists($MyCsv & ".csv")
    If $CsvFileExists Then
        ConsoleWrite("- Exists the Csv file:'" & $MyCsv & ".csv'" & @CRLF)
        $Txt &= "- Exists the Csv file:'" & $MyCsv & ".csv'" & @CRLF
    Else
        ConsoleWrite("! not found the Csv file:'" & $MyCsv & ".csv'" & @CRLF)
        $Txt &= "! not found the Csv file:'" & $MyCsv & ".csv'" & @CRLF
    EndIf

    GPOExit()

EndFunc   ;==>ExportCSV

 

I did not understand this code for export or for disable or enabled? 
I told you i want one script for export one  script for disable or enabled...
 

Link to comment
Share on other sites

15 hours ago, ioa747 said:

console out:  or the last piece of _GroupPolicy3.log

this logs for the last code you send for me 
 

$CmdLine[0]=4
$CmdLine[1]=\Computer Configuration\Administrative Templates\All Settings
$CmdLine[2]=CSV.File
$CmdLine[3]=0
$CmdLine[4]=C:\share\GPO-Export\2023-03-29--08-02-06
- $hGPO=0x0000000000080BEA
- $hTreeView_1=0x00000000011007AA
- CSV.File switch
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|All Settings
- $hControl=0x0000000000C10520
! not found the Csv file:'C:\share\GPO-Export\2023-03-29--08-02-06.csv'
- exit $hGPO=0x0000000000720AAC
+>08:02:15 AutoIt3.exe ended.rc:0
+>08:02:15 AutoIt3Wrapper Finished.

 

Link to comment
Share on other sites

On 3/27/2023 at 10:09 AM, ioa747 said:

run the script first, see if it works, and then from the command line

#RequireAdmin
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <Constants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>

;~ Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info  ; * <---

;==============================================================
; FUNCTION: _Example
; DESCRIPTION: This function opens the Group Policy Object Editor,
;   navigates to the specified policy setting, and changes its value
;   to the specified setting.
; PARAMETERS:
;   $CmdLine[1] - $sPolicyPath - The path of nodes to navigate
;   $CmdLine[2] - $sPolicyItem - The Item/option to navigate/edit
;   $CmdLine[3] - $iSetting    - T0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;   $CmdLine[4] - $sOption     - Optional Options in form "ClassnameNN;SendKey"
;==============================================================
; EXAMPLES:
; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0                                                          ; * - Normal
; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 3   ; * - Special
; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f"       ; * - With Option
; Global $CmdLine[5] = [4, "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0]

If Not $CmdLine[0] Then
    Global $CmdLine[5]
    $CmdLine[0] = 4 ;cnt
    $CmdLine[1] = "\Computer Configuration\Administrative Templates\Windows Components\Connect"
    $CmdLine[2] = "Require pin for pairing"
    $CmdLine[3] = 1
    $CmdLine[4] = "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" ;optional
EndIf

Global $iMsgBoxAnswer = "The setting" & @CRLF
$iMsgBoxAnswer &= $CmdLine[1] & @CRLF
$iMsgBoxAnswer &= $CmdLine[2] & @CRLF
$iMsgBoxAnswer &= "will be set to " & $CmdLine[3] & @CRLF

$iMsgBoxAnswer = MsgBox(4097, "This Msgbox will time out in 3 seconds", $iMsgBoxAnswer, 3)

Select
    Case $iMsgBoxAnswer = 1 ;OK
        ;nothing
    Case $iMsgBoxAnswer = 2 ;Cancel
        Exit
EndSelect

ConsoleWrite("$CmdLine[0]=" & $CmdLine[0] & @CRLF)

If $CmdLine[0] = 4 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3], $CmdLine[4])
ElseIf $CmdLine[0] = 3 Then
    _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3])
Else
    $iMsgBoxAnswer = MsgBox(4096, "incorect number of parameters", $CmdLine[0])
EndIf

Exit

; #FUNCTION# ;---------------------------------------------------------------------------
; Name...........: _GroupPolicy()
; Description ...: Opens and uses the Group Policy Editor to configure the given settings
; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting [, $sOption = ""])
; Parameters ....: $sPolicyPath     - The path of nodes to navigate
;                  $sPolicyItem     - The Item/option to navigate/edit
;                  $iSetting        - 0=Disabled, 1=Enabled, 2=Configured, 3=find & exit
;                  $sOption         - Options in form "ClassnameNN;SendKey"
;----------------------------------------------------------------------------------------
Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "")

    If Not WinExists("Local Group Policy Editor") Then
        Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a")
    EndIf

    ;Retrieves the 'Local Group Policy Editor' window handle
    Local $hGPO = WinWait("Local Group Policy Editor", '', 5)

    ConsoleWrite("$hGPO=" & $hGPO & @CRLF)

    ;Retrieves the SysTreeView321 control handle
    Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321")

    $sPolicyPath = "Local Computer Policy" & $sPolicyPath
    ConsoleWrite("--- $sPolicyPath=" & $sPolicyPath & @CRLF)
    ConsoleWrite("--- $sPolicyItem=" & $sPolicyItem & @CRLF)
    ConsoleWrite("--- $iSetting=" & $iSetting & @CRLF)
    ConsoleWrite("--- $sOption=" & $sOption & @CRLF)

    Local $aPath = StringSplit($sPolicyPath, "\", 1)
    Local $tmpPath = ""

    ;Expant the path in $hTreeView_1
    For $i = 1 To $aPath[0]
        $tmpPath &= $aPath[$i] & "|"
        ConsoleWrite("$tmpPath=" & StringTrimRight($tmpPath, 1) & @CRLF)
        ControlTreeView($hGPO, "", $hTreeView_1, "Expand", StringTrimRight($tmpPath, 1))
        ControlTreeView($hGPO, "", $hTreeView_1, "Select", StringTrimRight($tmpPath, 1))
        Sleep(50)
    Next

    ;at the bottom tabs we go right to the standard tab
    ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}")
    Sleep(50)

    ;Retrieves the SysListView321 control handle
    Local $hListView = ControlGetHandle($hGPO, "", "SysListView321")

    ;find the item
    Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem)
    Sleep(500)
    ConsoleWrite("- $FindItem=" & $FindItem & @CRLF)

    ;If not found then Return Error
    If $FindItem = -1 Then
        ConsoleWrite("not found the entry:'" & $sPolicyItem & "'" & @CRLF)
        Return SetError(1, 0, "")
    EndIf

    ;select the found item
    ControlListView($hGPO, "", $hListView, "Select", $FindItem)
    Sleep(50)

    ;snap Selected Item
    Local $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)

    Local $ItemTxt[4]
    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
    Next

    ;and send enter to open it
    ControlSend($hGPO, '', $hListView, '{ENTER}')

    ;---------------------------------------------------------------

    Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]", "", 1)
    ConsoleWrite("- $hGPOedit=" & $hGPOedit & @CRLF)

    If WinExists($hGPOedit) Then ; normal <-
        ConsoleWrite("> $hGPOedit=normal <" & @CRLF)
        Switch $iSetting
            Case 0 ;Disabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d")
                ConsoleWrite("-> Disabled" & @CRLF)

            Case 1 ;Enabled
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e")
                ConsoleWrite("-> Enabled" & @CRLF)

                If StringLen($sOption) > 0 Then
                    ConsoleWrite("- $sOption=" & $sOption & @CRLF)
                    Local $aOpt = StringSplit($sOption, ";", 1)
                    ControlSend($hGPOedit, "", $aOpt[1], $aOpt[2])
                EndIf

            Case 2 ;Configured
                ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c")
                ConsoleWrite("-> Configured" & @CRLF)

            Case 3 ;find & exit
                ConsoleWrite("-> find & exit" & @CRLF)
                Exit

        EndSwitch

        ;Apply
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "a")

        ;Enter
        ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "{ENTER}")

    Else ;special <-

        $hGPOedit = WinWait("[CLASS:#32770]", "", 1)

        ;Retrieve the window text of the active window.
        Local $sText = WinGetText($hGPOedit)
        ;ConsoleWrite($sText & @CRLF)
        If StringLeft($sText, 22) = "Local Security Setting" Then  ; * <- if "Local Security Setting"
            ConsoleWrite("> $hGPOedit=special <" & @CRLF)
            Switch $iSetting
                Case 0 ;Disabled
                    ControlSend($hGPOedit, "", "Button3", "s")
                    ConsoleWrite("-> Disabled" & @CRLF)

                Case 1 ;Enabled
                    ControlSend($hGPOedit, "", "Button2", "e")
                    ConsoleWrite("-> Enabled" & @CRLF)

                Case 3 ;find & exit
                    ConsoleWrite("-> find & exit" & @CRLF)
                    Exit

            EndSwitch
            ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}")
            Sleep(50)

            If WinExists("Confirm Setting Change") Then
                ControlSend("Confirm Setting Change", "", "Button1", "y") ; yes
            EndIf

        EndIf

    EndIf

    ;---------------------------------------------------------------

    ;snap Selected Item
    $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected")
    ConsoleWrite("- $SelectedItem=" & $SelectedItem & @CRLF)
    Sleep(50)

    ;Returns the text of a given Item to ItemTxt[0]=col0, item[1]=col1, ...
    For $i = 0 To 3
        $ItemTxt[$i] = ControlListView($hGPO, "", $hListView, "GetText", Int($SelectedItem), $i)
        ConsoleWrite("$ItemTxt[" & $i & "]=" & $ItemTxt[$i] & @CRLF)
    Next

;~  Exit  ; <-- ****************************************************

    Sleep(50)
    ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}")

    $hGPO = WinWait("Microsoft Management Console", "", 1)
    ControlSend($hGPO, "", "Static2", "{N}")

    Return $sPolicyItem

EndFunc   ;==>_GroupPolicy
;----------------------------------------------------------------------------------------

edit:

I deleted another one WinActivate()

 

for _GroupPolicy i run this code and the logs:

$CmdLine[0]=4
$hGPO=0x00000000005F0A14
--- $sPolicyPath=Local Computer Policy\Computer Configuration\Administrative Templates\Windows Components\Connect
--- $sPolicyItem=Require pin for pairing
--- $iSetting=1
--- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Connect
- $FindItem=-1
not found the entry:'Require pin for pairing'

i run it after again and it is working:
 

$CmdLine[0]=4
$hGPO=0x00000000009A0908
--- $sPolicyPath=Local Computer Policy\Computer Configuration\Administrative Templates\Windows Components\Connect
--- $sPolicyItem=Require pin for pairing
--- $iSetting=1
--- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Connect
- $FindItem=1
- $SelectedItem=1
$ItemTxt[0]=Require pin for pairing
$ItemTxt[1]=Not configured
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x0000000000C60520
> $hGPOedit=normal <
-> Enabled
- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
- $SelectedItem=1
$ItemTxt[0]=Require pin for pairing
$ItemTxt[1]=Enabled
$ItemTxt[2]=No
$ItemTxt[3]=

and once the logs 
 

$CmdLine[0]=4
$hGPO=0x0000000000270A80
--- $sPolicyPath=Local Computer Policy\Computer Configuration\Administrative Templates\Windows Components\Connect
--- $sPolicyItem=Require pin for pairing
--- $iSetting=1
--- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
$tmpPath=Local Computer Policy
$tmpPath=Local Computer Policy|Computer Configuration
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components
$tmpPath=Local Computer Policy|Computer Configuration|Administrative Templates|Windows Components|Connect
- $FindItem=1
- $SelectedItem=1
$ItemTxt[0]=Require pin for pairing
$ItemTxt[1]=Enabled
$ItemTxt[2]=No
$ItemTxt[3]=
- $hGPOedit=0x0000000000C3038A
> $hGPOedit=normal <
-> Enabled
- $sOption=WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f
- $SelectedItem=0
$ItemTxt[0]=Don't allow this PC to be projected to
$ItemTxt[1]=Enabled
$ItemTxt[2]=No
$ItemTxt[3]=

 

Edited by gal9
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...