Sign in to follow this  
Followers 0
DemonAngel

Control Panel Lockdown

4 posts in this topic

For those working on networks where some control panel entries are hidden by policies.

Instead of removing the policy and re-adding it when your done, try the following code.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------
#include <GuiConstants.au3>

GuiCreate("Control", 370, 350,-1, -1)
$list1 = GUICtrlCreateList("", 10, 10, 280, 350)
$button1 = GUICtrlCreateButton("Run Selected",290,10,80,20)
$button2 = GUICtrlCreateButton("EXIT",290,30,80,20)
GuiSetState()

poplist()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $button2
        ExitLoop
    Case $msg = $button1
        Runcpl()
    Case Else
    ;;;
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

Func Runcpl()
    Run (@Comspec & " /c start " &GUICtrlRead($list1))
EndFunc
Func poplist()
$search = FileFindFirstFile(@SystemDir &"\*.cpl")
If @error Then Return
    While 1
        $file = FileFindNextFile($search)
        If @error Then Return
        GUICtrlSetData($list1,$file)
    WEnd    
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

So you are finding all the control panel files (*.cpl) and attempting to run them.

Have you tested your code in a valid environment to see if it really works? I'd be interested to hear what OS version has policies that don't work.

Edited by Confuzzled

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

For those working on networks where some control panel entries are hidden by policies.

Great .. but not working here on a win98se ... use :

;Run (@Comspec & " /c start " &GUICtrlRead($list1))

Run("control.exe " &GUICtrlRead($list1))

EDIT:

control.exe >> hangs sometimes :

Run("rundll32 shell32,Control_RunDLL " &GUICtrlRead($list1))

Edited by Lapo

Share this post


Link to post
Share on other sites

patched two scripts together :

(NOT my work .. just copied & pasted)

#include <GUIConstants.au3>
#NoTrayIcon
Global Const $WM_COMMAND    = 0x0111
Global Const $LBN_SELCHANGE = 1
Global Const $LBN_DBLCLK    = 2

$Form2 = GUICreate("Menu", 300, 300, 302, 218, -1, $WS_EX_TOPMOST)
;GUISetIcon("C:\Documenti\Icone\cvbxbd.ico")
$GCCList = GUICtrlCreateList("", 10, 10, 220, 300)
$Label1 = GUICtrlCreateLabel("Menu", 20, 32, 140, 30)
;GUICtrlSetFont(-1, 20, 400, 0, "Century Gothic")
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)
poplist()

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case _IsPressed('0D') And ControlGetFocus($Form2) = 'ListBox1'
If GUICtrlRead($GCCList) then 
    Run("rundll32 shell32,Control_RunDLL " &GUICtrlRead($GCCList))
            Sleep(10); Delay not to run multiple copies
            Endif
            Exit
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    $hCtrl        = $lParam
    If $nID = $GCCList Then
        Switch $nNotifyCode                 
            Case $LBN_DBLCLK
If GUICtrlRead($GCCList) then 
Run("rundll32 shell32,Control_RunDLL " &GUICtrlRead($GCCList))
    EndIf
                    Exit
                Return 0
        EndSwitch
    EndIf
EndFunc

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
Local $a_R = DllCall($v_dll, "int","GetAsyncKeyState","int",'0x'&$s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

Func Runcpl()
   ;Run (@Comspec & " /c start " &GUICtrlRead($GCCList))
Run("rundll32 shell32,Control_RunDLL " &GUICtrlRead($GCCList))
EndFunc
Func poplist()
$search = FileFindFirstFile(@SystemDir &"\*.cpl")
If @error Then Return
    While 1
        $file = FileFindNextFile($search)
        If @error Then Return
        GUICtrlSetData($GCCList,$file)
    WEnd    
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0