ioa747 Posted March 22, 2023 Share Posted March 22, 2023 Alleluia gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 22, 2023 Share Posted March 22, 2023 3 minutes ago, gal9 said: now how i can to add to the code? you can help me with that please? please explain to me exactly what you want to put in your code gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 22, 2023 Author Share Posted March 22, 2023 (edited) 33 minutes ago, ioa747 said: please explain to me exactly what you want to put in your code expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ;============================================================== ; 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: ; $metric - The name of the policy setting to be changed. ; $setting - The value to which the policy setting should be changed. ; RETURNS: None. ;============================================================== If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable") MsgBox(4096, "message", "The setting "& $CmdLine[1] & " set to " & $CmdLine[2] & " This box will time out in 3 seconds", 3) Sleep(5000) Local $mtric =$CmdLine[1] ; "Allow Adobe Flash" Local $setting = $CmdLine[2] ;"disable" _Example($mtric,$setting) MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 3 seconds", 3) Exit(0) ; Finished! Func _selectDisEna($setting) Sleep(200) ; we give some time until the window appears Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]") ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16") For $i = 5 To 1 Step -1 If $setting = "disable" Or $setting ="Disabled" Then ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d") Sleep(3000) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a") EndIf If $setting = "enabled" Or $setting ="Enabled" Then ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e") Sleep(3000) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a") EndIf If $setting = "not configured" Or $setting ="Not configured" Then Send("{c}") EndIf ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{p}") Next ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}") EndFunc Func _Example($mtric,$setting) ; Run gpedit.msc ; Run("c:\Windows\system32\mmc.exe c:\Windows\system32\gpedit.msc /a") ;Run("c:\Windows\system32\mmc.exe C:\Users\" & @USERNAME &"\Desktop\script\gpedit_v1.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}{O}") ControlFocus($hGPO, "", "[TITLE:Filter Options]") WinWait("[TITLE:Filter Options]") Sleep(3500) If ControlCommand("Filter Options", "Enable &Keyword Filters", "Button2", "IsChecked", "") = 0 Then ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{K}{F}{ALT up}") Else ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{F}{ALT up}") EndIf Sleep(3500) ;;Type search ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", $mtric) Sleep(3500) ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ENTER}") ControlFocus($hGPO, "", $hTreeView_1) ControlSend($hGPO, "", $hTreeView_1, "a") ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") ;~ Sleep(1000) Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ControlFocus($hGPO, "", $hListView) ControlSend($hGPO, "", $hListView, "{HOME}") Sleep(2000) ControlSend($hGPO, "", $hListView, "{down 5}") Sleep(2000) Local $Item, $ItemCnt, $ItemTxt, $FindItem $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount") ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF) $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $mtric) ConsoleWrite("$FindItem=" & $FindItem & @CRLF) ControlListView($hGPO, "", $hListView, "Select", $FindItem) $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) ControlSend($hGPO, "", $hListView, "{Enter}") Sleep(3500) _selectDisEna($setting) ;Send ("{Ctrl}{S}") ;Send("^s") ;_Validation($mtric,$setting) Sleep(3500) 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}") ;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10) EndFunc this my code, now for example if the script search 'Allow Basic authentication' so I get tow two results so I will have Func search_by_path($path) and only for this example it is open the setting with the path '\Windows Components\Windows Remote Management (WinRM)\WinRM Service' will send enter for this and open the setting. and if I will have only one result so i do not call Func search_by_path($path) Let me know if you understand me Edited March 22, 2023 by gal9 Link to comment Share on other sites More sharing options...
ioa747 Posted March 22, 2023 Share Posted March 22, 2023 Sorry I went to make coffee I understand you I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 22, 2023 Share Posted March 22, 2023 The point is that in this case you should deliver the path And since you can't know when get one or more results , you should always deliver it in this sense, the first script was not better? expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator Local $sPath = "\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service" Local $sItem = "Allow Basic authentication" Local $sResult = _GroupPolicy($sPath, $sItem) Exit ; #FUNCTION# ;--------------------------------------------------------------------------- ; Name...........: _GroupPolicy() ; Description ...: Opens and uses the Group Policy Editor to configure the given settings ; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem [, $iMode = 2]) ; Parameters ....: $sPolicyPath - The path of nodes to navigate ; $sPolicyItem - The Item/option to navigate/edit ; $iMode - 0=Disabled, 1=Enabled, 2=Configured ; Author ........: ioa747 ; Notes .........: Testet on Win10(22H2) with AutoIt(3.3.16.1) ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iMode = 2) If Not WinExists("Local Group Policy Editor") Then Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") 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) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) ;find the item Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem) Sleep(100) 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) Exit ;and send enter to open ControlSend($hGPO, '', $hListView, '{ENTER}') ;Return $sPolicyItem ;give the window some time to appear Sleep(300) Local $sEditTitle = WinGetTitle("[ACTIVE]") ConsoleWrite("$sEditTitle=" & $sEditTitle & @CRLF) ;If WinTitle not $FindTxt then Return Error If $sEditTitle <> $sPolicyItem Then ConsoleWrite($sEditTitle & " not match to " & $sPolicyItem & @CRLF) Return SetError(1, 0, "") EndIf ;Retrieves the 'Editor' window handle Local $hGPOedit = WinWaitActive($sEditTitle) Switch $iMode Case 0 ;Disabled ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad15") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") ConsoleWrite("$iMode=Disabled" & @CRLF) Case 1 ;Enabled ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") ConsoleWrite("$iMode=Enabled" & @CRLF) Case 2 ;Configured ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ConsoleWrite("$iMode=Configured" & @CRLF) EndSwitch EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 22, 2023 Author Share Posted March 22, 2023 44 minutes ago, ioa747 said: The point is that in this case you should deliver the path And since you can't know when get one or more results , you should always deliver it in this sense, the first script was not better? expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator Local $sPath = "\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service" Local $sItem = "Allow Basic authentication" Local $sResult = _GroupPolicy($sPath, $sItem) Exit ; #FUNCTION# ;--------------------------------------------------------------------------- ; Name...........: _GroupPolicy() ; Description ...: Opens and uses the Group Policy Editor to configure the given settings ; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem [, $iMode = 2]) ; Parameters ....: $sPolicyPath - The path of nodes to navigate ; $sPolicyItem - The Item/option to navigate/edit ; $iMode - 0=Disabled, 1=Enabled, 2=Configured ; Author ........: ioa747 ; Notes .........: Testet on Win10(22H2) with AutoIt(3.3.16.1) ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iMode = 2) If Not WinExists("Local Group Policy Editor") Then Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") 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) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) ;find the item Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem) Sleep(100) 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) Exit ;and send enter to open ControlSend($hGPO, '', $hListView, '{ENTER}') ;Return $sPolicyItem ;give the window some time to appear Sleep(300) Local $sEditTitle = WinGetTitle("[ACTIVE]") ConsoleWrite("$sEditTitle=" & $sEditTitle & @CRLF) ;If WinTitle not $FindTxt then Return Error If $sEditTitle <> $sPolicyItem Then ConsoleWrite($sEditTitle & " not match to " & $sPolicyItem & @CRLF) Return SetError(1, 0, "") EndIf ;Retrieves the 'Editor' window handle Local $hGPOedit = WinWaitActive($sEditTitle) Switch $iMode Case 0 ;Disabled ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad15") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") ConsoleWrite("$iMode=Disabled" & @CRLF) Case 1 ;Enabled ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") ConsoleWrite("$iMode=Enabled" & @CRLF) Case 2 ;Configured ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ConsoleWrite("$iMode=Configured" & @CRLF) EndSwitch EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- This is exactly what I want to do to deliver the path every time. in the background, i have a python script call to AutoIt. I run it and manage it with Python. so in autoit i will add another parameter named path. and if i get more than one result so i call Func search_by_path($path) so if can help me To write the code I'm a bit stuck. Thank you very much! Link to comment Share on other sites More sharing options...
ioa747 Posted March 22, 2023 Share Posted March 22, 2023 Then why do they go into the process of putting a filter and seeing if it produces more than one then calling it with the path and calling it directly gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 22, 2023 Author Share Posted March 22, 2023 (edited) 11 minutes ago, ioa747 said: Then why do they go into the process of putting a filter and seeing if it produces more than one then calling it with the path and calling it directly I didn't understand you. i call autoit from python it is a tool to change GPO. I have a lot of settings I want to change but am getting some results I only want one specific one by a path. so if after the search i get only one result so it is not needed a path, Because there is only one of these names but if i have for example 'Allow Basic authentication' so i go over all and change to disable or enable Because i don't know how is the right one. but now after you help me so i can get the path. so if you can help me it is perfect Edited March 22, 2023 by gal9 Link to comment Share on other sites More sharing options...
ioa747 Posted March 22, 2023 Share Posted March 22, 2023 (edited) you have to tell me how you will deliver the path expandcollapse popup; https://www.autoitscript.com/forum/topic/209845-send-key-tab-jumps-somewhere-else/?do=findComment&comment=1515475 #RequireAdmin #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ;============================================================== ; 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: ; $metric - The name of the policy setting to be changed. ; $setting - The value to which the policy setting should be changed. ; RETURNS: None. ;============================================================== ;~ If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable") If Not $CmdLine[0] Then Global $CmdLine[3] = [2, "Allow Basic authentication", "disable"] EndIf MsgBox(4096, "message", "The setting " & $CmdLine[1] & " set to " & $CmdLine[2] & " This box will time out in 3 seconds", 3) Sleep(5000) Local $mtric = $CmdLine[1] ; "Allow Adobe Flash" Local $setting = $CmdLine[2] ;"disable" _Example($mtric, $setting) MsgBox(4096, "Test", "The setting saved and set " & $mtric & " to " & $setting & " This box will time out in 3 seconds", 3) Exit (0) ; Finished! Func _selectDisEna($setting) Sleep(200) ; we give some time until the window appears Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]") ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16") For $i = 5 To 1 Step -1 If $setting = "disable" Or $setting = "Disabled" Then ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d") Sleep(3000) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a") EndIf If $setting = "enabled" Or $setting = "Enabled" Then ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e") Sleep(3000) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a") EndIf If $setting = "not configured" Or $setting = "Not configured" Then Send("{c}") EndIf ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{p}") Next ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}") EndFunc ;==>_selectDisEna Func _Example($mtric, $setting) ; Run gpedit.msc ; Run("c:\Windows\system32\mmc.exe c:\Windows\system32\gpedit.msc /a") ;Run("c:\Windows\system32\mmc.exe C:\Users\" & @USERNAME &"\Desktop\script\gpedit_v1.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}{O}") ControlFocus($hGPO, "", "[TITLE:Filter Options]") WinWait("[TITLE:Filter Options]") Sleep(3500) If ControlCommand("Filter Options", "Enable &Keyword Filters", "Button2", "IsChecked", "") = 0 Then ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{K}{F}{ALT up}") Else ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{F}{ALT up}") EndIf Sleep(3500) ;;Type search ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", $mtric) Sleep(3500) ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ENTER}") ControlFocus($hGPO, "", $hTreeView_1) ControlSend($hGPO, "", $hTreeView_1, "a") ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(1000) Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ControlFocus($hGPO, "", $hListView) Sleep(50) ;Selects the first items. ControlListView($hGPO, "", $hListView, "Select", 0) Sleep(50) Local $Item, $ItemCnt, $ItemTxt, $FindItem $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount") ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF) $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) If $ItemCnt > 1 Then MsgBox(4096, "message", "here I found more lines that fit your criteria what to do ? ") EndIf Exit $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $mtric) ConsoleWrite("$FindItem=" & $FindItem & @CRLF) ControlListView($hGPO, "", $hListView, "Select", $FindItem) $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) ControlSend($hGPO, "", $hListView, "{Enter}") Sleep(3500) _selectDisEna($setting) ;Send ("{Ctrl}{S}") ;Send("^s") ;_Validation($mtric,$setting) Sleep(3500) 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}") ;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10) EndFunc ;==>_Example Edited March 22, 2023 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 22, 2023 Author Share Posted March 22, 2023 17 minutes ago, ioa747 said: you have to tell me how you will deliver the path expandcollapse popup; https://www.autoitscript.com/forum/topic/209845-send-key-tab-jumps-somewhere-else/?do=findComment&comment=1515475 #RequireAdmin #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ;============================================================== ; 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: ; $metric - The name of the policy setting to be changed. ; $setting - The value to which the policy setting should be changed. ; RETURNS: None. ;============================================================== ;~ If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable") If Not $CmdLine[0] Then Global $CmdLine[3] = [2, "Allow Basic authentication", "disable"] EndIf MsgBox(4096, "message", "The setting " & $CmdLine[1] & " set to " & $CmdLine[2] & " This box will time out in 3 seconds", 3) Sleep(5000) Local $mtric = $CmdLine[1] ; "Allow Adobe Flash" Local $setting = $CmdLine[2] ;"disable" _Example($mtric, $setting) MsgBox(4096, "Test", "The setting saved and set " & $mtric & " to " & $setting & " This box will time out in 3 seconds", 3) Exit (0) ; Finished! Func _selectDisEna($setting) Sleep(200) ; we give some time until the window appears Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]") ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16") For $i = 5 To 1 Step -1 If $setting = "disable" Or $setting = "Disabled" Then ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d") Sleep(3000) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a") EndIf If $setting = "enabled" Or $setting = "Enabled" Then ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e") Sleep(3000) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "a") EndIf If $setting = "not configured" Or $setting = "Not configured" Then Send("{c}") EndIf ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{p}") Next ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}") EndFunc ;==>_selectDisEna Func _Example($mtric, $setting) ; Run gpedit.msc ; Run("c:\Windows\system32\mmc.exe c:\Windows\system32\gpedit.msc /a") ;Run("c:\Windows\system32\mmc.exe C:\Users\" & @USERNAME &"\Desktop\script\gpedit_v1.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}{O}") ControlFocus($hGPO, "", "[TITLE:Filter Options]") WinWait("[TITLE:Filter Options]") Sleep(3500) If ControlCommand("Filter Options", "Enable &Keyword Filters", "Button2", "IsChecked", "") = 0 Then ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{K}{F}{ALT up}") Else ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ALT down}{F}{ALT up}") EndIf Sleep(3500) ;;Type search ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", $mtric) Sleep(3500) ControlSend("[TITLE:Filter Options]", "", "[CLASS:Edit; INSTANCE:1]", "{ENTER}") ControlFocus($hGPO, "", $hTreeView_1) ControlSend($hGPO, "", $hTreeView_1, "a") ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(1000) Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ControlFocus($hGPO, "", $hListView) Sleep(50) ;Selects the first items. ControlListView($hGPO, "", $hListView, "Select", 0) Sleep(50) Local $Item, $ItemCnt, $ItemTxt, $FindItem $ItemCnt = ControlListView($hGPO, "", $hListView, "GetItemCount") ConsoleWrite("$ItemCnt=" & $ItemCnt & @CRLF) $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) If $ItemCnt > 1 Then MsgBox(4096, "message", "here I found more lines that fit your criteria what to do ? ") EndIf Exit $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $mtric) ConsoleWrite("$FindItem=" & $FindItem & @CRLF) ControlListView($hGPO, "", $hListView, "Select", $FindItem) $SelectedItem = ControlListView($hGPO, "", $hListView, "GetSelected") ConsoleWrite("$SelectedItem=" & $SelectedItem & @CRLF) ControlSend($hGPO, "", $hListView, "{Enter}") Sleep(3500) _selectDisEna($setting) ;Send ("{Ctrl}{S}") ;Send("^s") ;_Validation($mtric,$setting) Sleep(3500) 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}") ;MsgBox(4096, "Test", "The setting saved and set "& $mtric & " to " & $setting & " This box will time out in 10 seconds", 10) EndFunc ;==>_Example in cmd like like this Local $mtric =$CmdLine[1] ; "Allow Adobe Flash" Local $setting = $CmdLine[2] Link to comment Share on other sites More sharing options...
gal9 Posted March 22, 2023 Author Share Posted March 22, 2023 1 hour ago, ioa747 said: The point is that in this case you should deliver the path And since you can't know when get one or more results , you should always deliver it in this sense, the first script was not better? expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator Local $sPath = "\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service" Local $sItem = "Allow Basic authentication" Local $sResult = _GroupPolicy($sPath, $sItem) Exit ; #FUNCTION# ;--------------------------------------------------------------------------- ; Name...........: _GroupPolicy() ; Description ...: Opens and uses the Group Policy Editor to configure the given settings ; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem [, $iMode = 2]) ; Parameters ....: $sPolicyPath - The path of nodes to navigate ; $sPolicyItem - The Item/option to navigate/edit ; $iMode - 0=Disabled, 1=Enabled, 2=Configured ; Author ........: ioa747 ; Notes .........: Testet on Win10(22H2) with AutoIt(3.3.16.1) ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iMode = 2) If Not WinExists("Local Group Policy Editor") Then Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") 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) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) ;find the item Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem) Sleep(100) 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) Exit ;and send enter to open ControlSend($hGPO, '', $hListView, '{ENTER}') ;Return $sPolicyItem ;give the window some time to appear Sleep(300) Local $sEditTitle = WinGetTitle("[ACTIVE]") ConsoleWrite("$sEditTitle=" & $sEditTitle & @CRLF) ;If WinTitle not $FindTxt then Return Error If $sEditTitle <> $sPolicyItem Then ConsoleWrite($sEditTitle & " not match to " & $sPolicyItem & @CRLF) Return SetError(1, 0, "") EndIf ;Retrieves the 'Editor' window handle Local $hGPOedit = WinWaitActive($sEditTitle) Switch $iMode Case 0 ;Disabled ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad15") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") ConsoleWrite("$iMode=Disabled" & @CRLF) Case 1 ;Enabled ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad16") ConsoleWrite("$iMode=Enabled" & @CRLF) Case 2 ;Configured ControlClick($hGPOedit, "", "WindowsForms10.BUTTON.app.0.297b065_r69_ad14") ConsoleWrite("$iMode=Configured" & @CRLF) EndSwitch EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- ok now i run it so you go path in menu Do you think this is a better solution? Link to comment Share on other sites More sharing options...
ioa747 Posted March 22, 2023 Share Posted March 22, 2023 i make remix expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ;============================================================== ; 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: ; $metric - The name of the policy setting to be changed. ; $setting - The value to which the policy setting should be changed. ; RETURNS: None. ;============================================================== ;~ If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable") If Not $CmdLine[0] Then Global $CmdLine[4] = [3, "\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service", "Allow Basic authentication", "disable"] ; 0=Disabled, 1=Enabled, 2=Configured EndIf Global $iMsgBoxAnswer = MsgBox(4097, "message", "The setting " & $CmdLine[1] & @CRLF & $CmdLine[2] & " set to " & $CmdLine[3] & " This box will time out in 5 seconds", 7) Select Case $iMsgBoxAnswer = 1 ;OK ;nothing Case $iMsgBoxAnswer = 2 ;Cancel Exit EndSelect Local $sResult = _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3]) Exit ; #FUNCTION# ;--------------------------------------------------------------------------- ; Name...........: _GroupPolicy() ; Description ...: Opens and uses the Group Policy Editor to configure the given settings ; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem [, $iMode = 2]) ; Parameters ....: $sPolicyPath - The path of nodes to navigate ; $sPolicyItem - The Item/option to navigate/edit ; $iMode - 0=Disabled, 1=Enabled, 2=Configured ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iMode = 2) If Not WinExists("Local Group Policy Editor") Then Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") 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) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Sleep(50) ;find the item Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem) Sleep(50) 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) ;and send enter to open ControlSend($hGPO, '', $hListView, '{ENTER}') ;Return $sPolicyItem ;give the window some time to appear Sleep(300) Sleep(200) ; we give some time until the window appears Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]") ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16") Switch $iMode Case 0 ;Disabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d") ConsoleWrite("$iMode=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e") ConsoleWrite("$iMode=Enabled" & @CRLF) Case 2 ;Configured ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c") ConsoleWrite("$iMode=Configured" & @CRLF) EndSwitch EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 22, 2023 Share Posted March 22, 2023 (edited) in line 142 i put Exit ; <-- ************************************************ so you can check if it's okay which is to turn it into a comment or delete it expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ;============================================================== ; 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] - The path of nodes to navigate. ; $CmdLine[2] - The name of the policy setting to be changed. ; $CmdLine[3] - The value of the policy setting to be changed 0=Disabled, 1=Enabled, 2=Configured ;============================================================== ; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0 If Not $CmdLine[0] Then Global $CmdLine[4] = [3, "\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service", "Allow Basic authentication", 0] EndIf Global $iMsgBoxAnswer = MsgBox(4097, "message", "The setting " & $CmdLine[1] & @CRLF & $CmdLine[2] & " set to " & $CmdLine[3] & @CRLF & " This box will time out in 5 seconds", 5) Select Case $iMsgBoxAnswer = 1 ;OK ;nothing Case $iMsgBoxAnswer = 2 ;Cancel Exit EndSelect If $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 [, $iMode = 2]) ; Parameters ....: $sPolicyPath - The path of nodes to navigate ; $sPolicyItem - The Item/option to navigate/edit ; $iMode - 0=Disabled, 1=Enabled, 2=Configured ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iMode = 2) If Not WinExists("Local Group Policy Editor") Then Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") ConsoleWrite("$hGPO=" & $hGPO & @CRLF) ;Retrieves the SysTreeView321 control handle Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321") ;Sets the focus to $hTreeView_1 ControlFocus($hGPO, "", $hTreeView_1) Sleep(50) $sPolicyPath = "Local Computer Policy" & $sPolicyPath ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF) ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ;ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Sleep(50) ;find the item Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem) Sleep(250) 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) ;and send enter to open it ControlSend($hGPO, '', $hListView, '{ENTER}') ; we give some time until the edit window appears Sleep(100) Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]") ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16") Switch $iMode Case 0 ;Disabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d") ConsoleWrite("$iMode=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e") ConsoleWrite("$iMode=Enabled" & @CRLF) Case 2 ;Configured ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c") ConsoleWrite("$iMode=Configured" & @CRLF) EndSwitch ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad112", "{ENTER}") Sleep(50) Exit ; <-- ************************************************ ControlFocus($hGPO, "", $hTreeView_1) ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}") Sleep(50) Local $hGPO = WinWait("Microsoft Management Console") ControlSend($hGPO, "", "[CLASS:Static; INSTANCE:2]", "{N}") Return $sPolicyItem EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- Edited March 23, 2023 by ioa747 gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 24, 2023 Author Share Posted March 24, 2023 On 3/22/2023 at 8:48 PM, ioa747 said: i make remix expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ;============================================================== ; 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: ; $metric - The name of the policy setting to be changed. ; $setting - The value to which the policy setting should be changed. ; RETURNS: None. ;============================================================== ;~ If Not $CmdLine[0] Then Exit Run(@AutoItExe & " " & @ScriptFullPath & " /Allow Adobe Flash /param2 disable") If Not $CmdLine[0] Then Global $CmdLine[4] = [3, "\Computer Configuration\Administrative Templates\Windows Components\Windows Remote Management (WinRM)\WinRM Service", "Allow Basic authentication", "disable"] ; 0=Disabled, 1=Enabled, 2=Configured EndIf Global $iMsgBoxAnswer = MsgBox(4097, "message", "The setting " & $CmdLine[1] & @CRLF & $CmdLine[2] & " set to " & $CmdLine[3] & " This box will time out in 5 seconds", 7) Select Case $iMsgBoxAnswer = 1 ;OK ;nothing Case $iMsgBoxAnswer = 2 ;Cancel Exit EndSelect Local $sResult = _GroupPolicy($CmdLine[1], $CmdLine[2], $CmdLine[3]) Exit ; #FUNCTION# ;--------------------------------------------------------------------------- ; Name...........: _GroupPolicy() ; Description ...: Opens and uses the Group Policy Editor to configure the given settings ; Syntax.........: _GroupPolicy($sPolicyPath, $sPolicyItem [, $iMode = 2]) ; Parameters ....: $sPolicyPath - The path of nodes to navigate ; $sPolicyItem - The Item/option to navigate/edit ; $iMode - 0=Disabled, 1=Enabled, 2=Configured ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iMode = 2) If Not WinExists("Local Group Policy Editor") Then Run("c:\Windows\system32\mmc.exe " & "C:\share\open_close_gpedit\gpedit_v1.msc /a") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") 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) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Sleep(50) ;find the item Local $FindItem = ControlListView($hGPO, "", $hListView, "FindItem", $sPolicyItem) Sleep(50) 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) ;and send enter to open ControlSend($hGPO, '', $hListView, '{ENTER}') ;Return $sPolicyItem ;give the window some time to appear Sleep(300) Sleep(200) ; we give some time until the window appears Local $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.297b065_r69_ad1]") ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16") Switch $iMode Case 0 ;Disabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "d") ConsoleWrite("$iMode=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "e") ConsoleWrite("$iMode=Enabled" & @CRLF) Case 2 ;Configured ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.297b065_r69_ad16", "c") ConsoleWrite("$iMode=Configured" & @CRLF) EndSwitch EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- you are champ! I didn't see you using search ,but if you say it is better to go according path so do what you say so I will try to challenge you i have two more problems and i don't know if create new script for "special" 1. if i have setting i want change not in "all setting" you recommend create new script for example if i want change "Ensure 'Microsoft network client: Digitally sign communications (always)' is set to 'Enabled'" Or another example Ensure 'Accounts: Administrator account status' is set to 'Disabled' 2. the Second problem after i do enabled, open for me options and sometimes it need select options sometimes i need send key Ensure 'Require pin for pairing' is set to 'Enabled: First Time' Link to comment Share on other sites More sharing options...
ioa747 Posted March 24, 2023 Share Posted March 24, 2023 I don't have time now, I'll look at it in the afternoon gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 24, 2023 Share Posted March 24, 2023 (edited) I modified it according to the new requirements save it with the name _GroupPolicy2.au3 expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #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] - The path of nodes to navigate. ; $CmdLine[2] - The name of the policy setting to be changed. ; $CmdLine[3] - The value of the policy setting to be changed 0=Disabled, 1=Enabled, 2=Configured ; $CmdLine[4] - Options in form "ClassnameNN;SendKey" ;============================================================== ; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0 If Not $CmdLine[0] Then Global $CmdLine[5] = [4, "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 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 ; $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") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") ConsoleWrite("$hGPO=" & $hGPO & @CRLF) ;Retrieves the SysTreeView321 control handle Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321") ;Sets the focus to $hTreeView_1 ControlFocus($hGPO, "", $hTreeView_1) Sleep(50) $sPolicyPath = "Local Computer Policy" & $sPolicyPath ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF) ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ;ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Sleep(50) ;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) ;and send enter to open it ControlSend($hGPO, '', $hListView, '{ENTER}') ;--------------------------------------------------------------- Local $hGPOedit $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.125ada7_r69_ad1]", "", 1) ConsoleWrite("$hGPOedit=" & $hGPOedit & @CRLF) If WinExists($hGPOedit) Then ; normal ConsoleWrite("$hGPOedit=normal" & @CRLF) ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16") Switch $iSetting Case 0 ;Disabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16", "d") ConsoleWrite("$iSetting=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16", "e") ConsoleWrite("$iSetting=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.125ada7_r69_ad16", "c") ConsoleWrite("$iSetting=Configured" & @CRLF) EndSwitch Sleep(50) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_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 ConsoleWrite("$hGPOedit=special" & @CRLF) Switch $iSetting Case 0 ;Disabled ControlSend($hGPOedit, "", "Button3", "s") ConsoleWrite("$iSetting=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "Button2", "e") ConsoleWrite("$iSetting=Enabled" & @CRLF) EndSwitch ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}") Sleep(50) EndIf EndIf ;--------------------------------------------------------------- ;~ Exit ; <-- **************************************************** ControlFocus($hGPO, "", $hTreeView_1) Sleep(50) ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}") $hGPO = WinWait("Microsoft Management Console") ControlSend($hGPO, "", "Static2", "{N}") Return $sPolicyItem EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- put the in the same folder, the example with the name Call_GroupPolicy2.au3 #RequireAdmin #AutoIt3Wrapper_UseX64=y ; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Accounts: Administrator account status", 0 ; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 1 ; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" _GroupPolicy("\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Accounts: Administrator account status", 0) _GroupPolicy("\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 1) _GroupPolicy("\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f") ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "") Local $FilePath = @ScriptDir & "\_GroupPolicy2.au3" Local $Param = '"' & $sPolicyPath & '" "' & $sPolicyItem & '" "' & $iSetting & '" "' & $sOption & '"' RunWait(FileGetShortName(@AutoItExe) & " " & FileGetShortName($FilePath) & " " & $Param) EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- and run it Edited March 24, 2023 by ioa747 gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 24, 2023 Share Posted March 24, 2023 you are welcome gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 26, 2023 Author Share Posted March 26, 2023 (edited) On 3/24/2023 at 8:47 PM, ioa747 said: I modified it according to the new requirements save it with the name _GroupPolicy2.au3 expandcollapse popup#RequireAdmin #AutoIt3Wrapper_UseX64=y #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] - The path of nodes to navigate. ; $CmdLine[2] - The name of the policy setting to be changed. ; $CmdLine[3] - The value of the policy setting to be changed 0=Disabled, 1=Enabled, 2=Configured ; $CmdLine[4] - Options in form "ClassnameNN;SendKey" ;============================================================== ; "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 0 If Not $CmdLine[0] Then Global $CmdLine[5] = [4, "\Computer Configuration\Administrative Templates\Windows Components\Microsoft Edge", "Allow Adobe Flash", 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 ; $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") WinWait("Local Group Policy Editor", '', 5) EndIf ;Retrieves the 'Local Group Policy Editor' window handle Local $hGPO = WinActivate("Local Group Policy Editor") ConsoleWrite("$hGPO=" & $hGPO & @CRLF) ;Retrieves the SysTreeView321 control handle Local $hTreeView_1 = ControlGetHandle($hGPO, "", "SysTreeView321") ;Sets the focus to $hTreeView_1 ControlFocus($hGPO, "", $hTreeView_1) Sleep(50) $sPolicyPath = "Local Computer Policy" & $sPolicyPath ConsoleWrite("$sPolicyPath=" & $sPolicyPath & @CRLF) ConsoleWrite("$sPolicyItem=" & $sPolicyItem & @CRLF) Local $aPath = StringSplit($sPolicyPath, "\", 1) Local $tmpPath = "" ;ConsoleWrite("" & @CRLF) 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 ControlFocus($hGPO, "", "AMCCustomTab1") ControlSend($hGPO, "", "AMCCustomTab1", "{RIGHT}") Sleep(50) ;Retrieves the SysListView321 control handle Local $hListView = ControlGetHandle($hGPO, "", "SysListView321") ;Sets the focus to SysListView321 ControlFocus($hGPO, "", $hListView) Sleep(50) ;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) ;and send enter to open it ControlSend($hGPO, '', $hListView, '{ENTER}') ;--------------------------------------------------------------- Local $hGPOedit $hGPOedit = WinWait("[CLASS:WindowsForms10.Window.8.app.0.125ada7_r69_ad1]", "", 1) ConsoleWrite("$hGPOedit=" & $hGPOedit & @CRLF) If WinExists($hGPOedit) Then ; normal ConsoleWrite("$hGPOedit=normal" & @CRLF) ControlFocus($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16") Switch $iSetting Case 0 ;Disabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16", "d") ConsoleWrite("$iSetting=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16", "e") ConsoleWrite("$iSetting=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.125ada7_r69_ad16", "c") ConsoleWrite("$iSetting=Configured" & @CRLF) EndSwitch Sleep(50) ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_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 ConsoleWrite("$hGPOedit=special" & @CRLF) Switch $iSetting Case 0 ;Disabled ControlSend($hGPOedit, "", "Button3", "s") ConsoleWrite("$iSetting=Disabled" & @CRLF) Case 1 ;Enabled ControlSend($hGPOedit, "", "Button2", "e") ConsoleWrite("$iSetting=Enabled" & @CRLF) EndSwitch ControlSend($hGPOedit, "", "SysTabControl321", "{ENTER}") Sleep(50) EndIf EndIf ;--------------------------------------------------------------- ;~ Exit ; <-- **************************************************** ControlFocus($hGPO, "", $hTreeView_1) Sleep(50) ControlSend($hGPO, "", $hTreeView_1, "{ALT down}{F4}{ALT up}") $hGPO = WinWait("Microsoft Management Console") ControlSend($hGPO, "", "Static2", "{N}") Return $sPolicyItem EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- put the in the same folder, the example with the name Call_GroupPolicy2.au3 #RequireAdmin #AutoIt3Wrapper_UseX64=y ; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Accounts: Administrator account status", 0 ; "\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 1 ; "\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" _GroupPolicy("\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Accounts: Administrator account status", 0) _GroupPolicy("\Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options", "Microsoft network client: Digitally sign communications (always)", 1) _GroupPolicy("\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f") ;---------------------------------------------------------------------------------------- Func _GroupPolicy($sPolicyPath, $sPolicyItem, $iSetting, $sOption = "") Local $FilePath = @ScriptDir & "\_GroupPolicy2.au3" Local $Param = '"' & $sPolicyPath & '" "' & $sPolicyItem & '" "' & $iSetting & '" "' & $sOption & '"' RunWait(FileGetShortName(@AutoItExe) & " " & FileGetShortName($FilePath) & " " & $Param) EndFunc ;==>_GroupPolicy ;---------------------------------------------------------------------------------------- and run it WOW thanks' man!! it's wonderful! i think i have Two problems 1. after i select Disabled or Enabled and opens for me Popuphttps://fileport.io/gJzyn7RDmp9A and I don't know if it's because of an error that failed to close the GPO. and run only this line _GroupPolicy("\Computer Configuration\Administrative Templates\Windows Components\Connect", "Require pin for pairing", 1, "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f") it doesn't do enable it do disable I'll try to fix it now 2. I try to call from cmd i run as administrator i call https://fileport.io/U74M1NYZmhWF ``` _GroupPolicy2.au3 "\Computer Configuration\Administrative Templates\Windows Components\Connect" "Require pin for pairing" "1" "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11;f" ``` in past, I would call ``` poledit_open_close.au3 "allow basic authentication" "enabled" ``` and the parameters were sent Thank you so much for all the support! Edited March 26, 2023 by gal9 Link to comment Share on other sites More sharing options...
ioa747 Posted March 26, 2023 Share Posted March 26, 2023 34 minutes ago, gal9 said: 1. after i select Disabled or Enabled i need to send 'Apply' After this send 'OK' above the enter (line 163) , we set it to send a for Aply ; Apply ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16", "a") 57 minutes ago, gal9 said: 2. I try to call from cmd i run as administrator i call at a glance, without checking the parameters, to run the script in this form C:\Users\autotest\Desktop\autoit_test>_GroupPolicy2.au3 "\Computer Configuration\Administrative Templates\Windows Components\Connect" "Require pin for pairing" "1" "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11; f" It doesn't work. You will compile it into an executable exe or using the interpreter look in your help for Command Line Parameters Run a script using the interpreter: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] filename [params ...] Execute the AutoIt3 script 'filename' with optional parameters At its simplest: AutoIt3.exe myScript.au3 will run a standard AutoIt script 'myScript.au3' with no parameters. Run a compiled script: Compiled.exe [/ErrorStdOut] [params ...] Execute a compiled AutoIt3 Script File produced with Aut2Exe. gal9 1 I know that I know nothing Link to comment Share on other sites More sharing options...
gal9 Posted March 26, 2023 Author Share Posted March 26, 2023 1 minute ago, ioa747 said: above the enter (line 163) , we set it to send a for Aply ; Apply ControlSend($hGPOedit, "", "WindowsForms10.Window.8.app.0.125ada7_r69_ad16", "a") at a glance, without checking the parameters, to run the script in this form C:\Users\autotest\Desktop\autoit_test>_GroupPolicy2.au3 "\Computer Configuration\Administrative Templates\Windows Components\Connect" "Require pin for pairing" "1" "WindowsForms10.COMBOBOX.app.0.297b065_r69_ad11; f" It doesn't work. You will compile it into an executable exe or using the interpreter look in your help for Command Line Parameters Run a script using the interpreter: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] filename [params ...] Execute the AutoIt3 script 'filename' with optional parameters At its simplest: AutoIt3.exe myScript.au3 will run a standard AutoIt script 'myScript.au3' with no parameters. Run a compiled script: Compiled.exe [/ErrorStdOut] [params ...] Execute a compiled AutoIt3 Script File produced with Aut2Exe. 1. about apply does not solve the problem I think.. but I dot it is safer... i need do if if jumps Popup 2. I will check now the cmd and compile for parameters and will update you 3. Require pin for pairing to Enabled i try to add sleep it is not work https://fileport.io/SEvYva9WBZbf for you it is working? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now