Jump to content
Sign in to follow this  
Iznogoud

Enable/Dsiable Group Policy settings

Recommended Posts

SmOke_N

Here, all you have to do this way, is enter the list view text to find in the call to the function:

Local $TextToFind = 'Remove Documents menu from Start Menu'
_GroupPolicy($TextToFind)

Func _GroupPolicy($sPolicyItem, $sTitle = 'Group Policy', $sClassNName = 'SysListView321')
    Local $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem)
    ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
    ControlSend($sTitle, '', $sClassNName, '{ENTER}')
EndFunc

Edit:

Oops, Zedna beat me to it :D.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Iznogoud

Just use it in Function:

Func OpenItem($TextToFind)
    Local $Title = "Group Policy"
    Local $Item = ControlListView($Title, '', 'SysListView321', 'FindItem', $TextToFind)
    ControlListView($Title, '', 'SysListView321', 'Select', $Item)
    ControlSend($Title, '', 'SysListView321', '{ENTER}')
EndFunc

OpenItem('Remove Documents menu from Start Menu')
OpenItem('Remote programs on Settings menu')
OpenItem('Remote My Network Places icon from Start Menu')
:D thats really nice. The possiblities are endless :D

Hmmm, i will combine this with the treelist and will try to get it to work. For this far thanks. And i will post my script when its read for other people if they want to do the same.

-EDIT-

Thanks to you too Sm0ke_N :P

Edited by Iznogoud

Share this post


Link to post
Share on other sites
JSThePatriot

I could have swore I searched through the registry...I will try again. I have searched the internet, but have as of yet been unable to find what I feel I am looking for. I must not be searching the right terms.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites
seandisanti

I could have swore I searched through the registry...I will try again. I have searched the internet, but have as of yet been unable to find what I feel I am looking for. I must not be searching the right terms.

JS

items that show as 'not configured' in gpedit do not have registry entries yet, those set to disabled or enabled do... you can add the registry entries for ones that are not yet configured, i'll see if i can't find my book this afternoon and i'll scan those pages for you

Share this post


Link to post
Share on other sites
SmOke_N

My "basic" understanding of the group policy is it's not in the same spot in the registry "all" the time... I think I read that some where last year :D.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
emendelson

The key you're looking for is HKLM\SECURITY, but it's normally not accessible, even to administrative users, unless you change the key's permissions. If you want to explore this key, it's easier to do so with a third-party utility like Registry Workshop than it is with RegEdit, I've found.

Share this post


Link to post
Share on other sites
seandisanti

The key you're looking for is HKLM\SECURITY, but it's normally not accessible, even to administrative users, unless you change the key's permissions. If you want to explore this key, it's easier to do so with a third-party utility like Registry Workshop than it is with RegEdit, I've found.

the keys are actually scattered dependant on what types of policies they are, and i've not had problems deleting them programatically to disable policies... there are also command line apps (i want to say setacl is one, but a few are mentioned in the forums) that can be used to change permissions on registry keys if someone DOES run into a snag with permissions...

Share this post


Link to post
Share on other sites
Iznogoud

But this way like policies, you easily manage them at one place. You can do it within your login script. But i want a fast login :D

But i encounter one problem, how can i select the 2nd item in a tree wich have the same name?

So i got for an example

- Title1

-- item1

-- item2

-- item3

- Title2

-- item3

-- item4

If i want to select the item3 wich is under Title 2, how can i do this?

I with my simple thinking though i could do twice the same code like:

SelectTreeViewItemByName($tree, "item3")
SelectTreeViewItemByName($tree, "item3")

But he keeps selecting the first one.

Share this post


Link to post
Share on other sites
SmOke_N

Which policy are you talking about there?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Iznogoud

Which policy are you talking about there?

If you look at this picture you got a system at the User configuration, but you got also one under Computer configurations.

Here do you have the pic again:

Posted Image

So if i send this:

SelectTreeViewItemByName($tree, "system")

It selects the system under the Computer configurations, but i also want to change settings in the User configurations.

But how can i select the second system ?

Share this post


Link to post
Share on other sites
SmOke_N

This seemed to work, you may have to play with the sleeps a tad though, my machine is fairly fast:

If Not WinExists('Group Policy') Then
    Run(@ComSpec & ' /c ' & 'gpedit.msc', "", @SW_HIDE);gpedit.msc is what mine is called
    WinWait('Group Policy', '', 5)
    Sleep(500)
EndIf

Local $aTextItems[4] = ['User Configuration', 'Administrative Templates', 'Start Menu and Taskbar', 'Remove Documents menu from Start Menu']
For $iCount = 0 To UBound($aTextItems) - 1
    _GroupPolicy($aTextItems[$iCount])
    Sleep(100)
Next

Func _GroupPolicy($sPolicyItem, $sSubPolicyItem = '', $sTitle = 'Group Policy', $sClassNName = 'SysListView321')
    Local $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem, $sSubPolicyItem)
    ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
    ControlSend($sTitle, '', $sClassNName, '{ENTER}')
EndFunc


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Zedna

But i encounter one problem, how can i select the 2nd item in a tree wich have the same name?

So i got for an example

- Title1

-- item1

-- item2

-- item3

- Title2

-- item3

-- item4

If i want to select the item3 wich is under Title 2, how can i do this?

I with my simple thinking though i could do twice the same code like:

SelectTreeViewItemByName($tree, "item3")
SelectTreeViewItemByName($tree, "item3")

But he keeps selecting the first one.

Try something like this:

$node_root = TreeViewGetRoot($tree)
$node_comp = TreeViewNextSibling($tree, $node_root) ; computer
$node_user = TreeViewNextSibling($tree, $node_comp) ; user
ExpandTreeViewItem($tree, $node_user)
$node = TreeViewNextChild($tree, $node_user)
While $node
    $node_text = GetTreeViewNameByItem($tree, $node)
    If $node_text = 'System' Then 
        SelectTreeViewItem($tree, $node)
        ExitLoop
    EndIf
    $node = TreeViewNextSibling($tree, $node)
WEnd

Share this post


Link to post
Share on other sites
Iznogoud

This seemed to work, you may have to play with the sleeps a tad though, my machine is fairly fast:

If Not WinExists('Group Policy') Then
    Run(@ComSpec & ' /c ' & 'gpedit.msc', "", @SW_HIDE);gpedit.msc is what mine is called
    WinWait('Group Policy', '', 5)
    Sleep(500)
EndIf

Local $aTextItems[4] = ['User Configuration', 'Administrative Templates', 'Start Menu and Taskbar', 'Remove Documents menu from Start Menu']
For $iCount = 0 To UBound($aTextItems) - 1
    _GroupPolicy($aTextItems[$iCount])
    Sleep(100)
Next

Func _GroupPolicy($sPolicyItem, $sSubPolicyItem = '', $sTitle = 'Group Policy', $sClassNName = 'SysListView321')
    Local $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem, $sSubPolicyItem)
    ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
    ControlSend($sTitle, '', $sClassNName, '{ENTER}')
EndFunc
Hmm ok, the code you have written before wich i also just posted above is easier to understand :D

If i compair the code from you and Sm0ke_N, i would choose Sm0ke_N's code, because you can put the full path of the tree with the listitem in it. But maybe this is also i don't understand yours.

I am trying to understand is and will run the code :P

If i had 1% of the knowledge of you guys from AutoIT, i wouldn't asked these things :D

-EDIT-

If have tried to make the function myself.

This is what i got:

OpenTreeItem('Gebruikersconfiguratie', 'Beheersjablonen', 'Menu Start & Taakbalk', 'Netwerkverbindingen uit het menu Start verwijderen')

Func OpenTreeItem($TreeItemToFind)
    Local $aTextItems[4] = [$TreeItemToFind]
        For $iCount = 0 To UBound($aTextItems) - 1
        _GroupPolicy($aTextItems[$iCount])
        Sleep(100)
    Next

Func _GroupPolicy($sPolicyItem, $sSubPolicyItem = '', $sTitle = 'Groepsbeleid', $sClassNName = 'SysListView321')
    Local $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem, $sSubPolicyItem)
    ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
    ControlSend($sTitle, '', $sClassNName, '{ENTER}')
EndFunc

But you can't call a funtion with more then 1 argument. So is there an other way or must i use stringsplit to get the variables? or just copy for each settings the:

Local $aTextItems[4] = ['User Configuration', 'Administrative Templates', 'Start Menu and Taskbar', 'Remove Documents menu from Start Menu']
For $iCount = 0 To UBound($aTextItems) - 1
    _GroupPolicy($aTextItems[$iCount])
    Sleep(100)
Next
Edited by Iznogoud

Share this post


Link to post
Share on other sites
Iznogoud

Not possible to get it in a function? As i described above?

Share this post


Link to post
Share on other sites
SmOke_N

Not possible to get it in a function? As i described above?

I don't know, to be honest, I haven't even looked, I figured since "we" had done so much, surely you could figure that part out :D ... No seriously, what have you done to try and do it?

Edit:

Mine is pretty straight forward if you are familiar with arrays... you simply add one or take one away as you need it, or create another array and do another For/Next loop. Now remember, if you add to it, then you must also add an extra number: So [4] now becomes [5] if I add one.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Iznogoud

I don't know, to be honest, I haven't even looked, I figured since "we" had done so much, surely you could figure that part out :D ... No seriously, what have you done to try and do it?

Edit:

Mine is pretty straight forward if you are familiar with arrays... you simply add one or take one away as you need it, or create another array and do another For/Next loop. Now remember, if you add to it, then you must also add an extra number: So [4] now becomes [5] if I add one.

Thats not the problem, i have figured that out my self :P

The question how can i get in a function so i dont have to copy this whole piece:

Local $aTextItems[6] = ['Computer Configuration', 'Windows Settings', 'Security Settings', 'Local Policies', 'Security Options', 'Devices: Restrict floppy access to locally logged-on user only']
    For $iCount = 0 To UBound($aTextItems) - 1
        _GroupPolicyEnable($aTextItems[$iCount])
        Sleep(100)
    Next

If i could it like this in a function so i only need something like:

Fucntion(Local $aTextItems[6] = ['Computer Configuration', 'Windows Settings', 'Security Settings', 'Local Policies', 'Security Options', 'Devices: Restrict floppy access to locally logged-on user only'])

But i have tried it to put this in a function, but my skills are a bit straight forward and not yet filled with the knowledge of arrays etc. Ok i can link the connection if i add an array to your code i have increase the number. I am not THAT stupid :D

Share this post


Link to post
Share on other sites
SmOke_N

What's so hard about adding it? You could send the Array and do a for next loop in the function. Now you could use what I gave you originally, or:

Local $aTextItems[4] = ['User Configuration', 'Administrative Templates', 'Start Menu and Taskbar', 'Remove Documents menu from Start Menu']
_GroupPolicy($aTextItems)

Func _GroupPolicy($sPolicyItem, $sTitle = 'Group Policy', $sClassNName = 'SysListView321')
    Local $iItem = ''
    If IsArray($sPolicyItem) Then
        For $iCount = 0 To UBound($sPolicyItem) - 1
            $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem[$iCount])
            ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
            ControlSend($sTitle, '', $sClassNName, '{ENTER}')
            Sleep(100)
        Next
    Else
        $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem)
        ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
        ControlSend($sTitle, '', $sClassNName, '{ENTER}')
    EndIf
EndFuncoÝ÷ Øêâ*.­æ¥,Ø­¶ÞnédɩݺyÞqë,j¼ºÚ"µÍÑÜÝÛXÞJ
B[ÈÑÜÝÛXÞJ    ÌÍÜÔÛXÞR][LHH ÌÎNÕÙÛÛYÝ][ÛÌÎNË ÌÍÜÔÛXÞR][LH  ÌÎNÐYZ[Ý]]H[]ÉÌÎNËÂBBIÌÍÜÔÛXÞR][LÈH ÌÎNÔÝY[H[ÚØÌÎNË    ÌÍÜÔÛXÞR][MH  ÌÎNÔ[[ÝHØÝ[Y[ÈY[HÛHÝY[IÌÎNËÂBBIÌÍÜÕ]HH ÌÎNÑÜÝÛXÞIÌÎNË    ÌÍÜÐÛÜÓ[YHH  ÌÎNÔÞÓÝY]ÌÌIÌÎNÊBBSØØ[ ÌÍÚR][HHÛÛÛÝY]Ê ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][LJBBPÛÛÛÝY]Ê   ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
BBIÌÍÚR][HHÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][LBBPÛÛÛÝY]Ê    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
BBIÌÍÚR][HHÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][LÊBBPÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
BBIÌÍÚR][HHÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][M
BBPÛÛÛÝY]Ê ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
B[[


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Iznogoud

What's so hard about adding it? You could send the Array and do a for next loop in the function. Now you could use what I gave you originally, or:

Local $aTextItems[4] = ['User Configuration', 'Administrative Templates', 'Start Menu and Taskbar', 'Remove Documents menu from Start Menu']
_GroupPolicy($aTextItems)

Func _GroupPolicy($sPolicyItem, $sTitle = 'Group Policy', $sClassNName = 'SysListView321')
    Local $iItem = ''
    If IsArray($sPolicyItem) Then
        For $iCount = 0 To UBound($sPolicyItem) - 1
            $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem[$iCount])
            ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
            ControlSend($sTitle, '', $sClassNName, '{ENTER}')
            Sleep(100)
        Next
    Else
        $iItem = ControlListView($sTitle, '', $sClassNName, 'FindItem', $sPolicyItem)
        ControlListView($sTitle, '', $sClassNName, 'Select', $iItem)
        ControlSend($sTitle, '', $sClassNName, '{ENTER}')
    EndIf
EndFuncoÝ÷ Øêâ*.­æ¥,Ø­¶ÞnédɩݺyÞqë,j¼ºÚ"µÍÑÜÝÛXÞJ
B[ÈÑÜÝÛXÞJ    ÌÍÜÔÛXÞR][LHH ÌÎNÕÙÛÛYÝ][ÛÌÎNË ÌÍÜÔÛXÞR][LH  ÌÎNÐYZ[Ý]]H[]ÉÌÎNËÂBBIÌÍÜÔÛXÞR][LÈH ÌÎNÔÝY[H[ÚØÌÎNË    ÌÍÜÔÛXÞR][MH  ÌÎNÔ[[ÝHØÝ[Y[ÈY[HÛHÝY[IÌÎNËÂBBIÌÍÜÕ]HH ÌÎNÑÜÝÛXÞIÌÎNË    ÌÍÜÐÛÜÓ[YHH  ÌÎNÔÞÓÝY]ÌÌIÌÎNÊBBSØØ[ ÌÍÚR][HHÛÛÛÝY]Ê ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][LJBBPÛÛÛÝY]Ê   ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
BBIÌÍÚR][HHÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][LBBPÛÛÛÝY]Ê    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
BBIÌÍÚR][HHÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][LÊBBPÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
BBIÌÍÚR][HHÛÛÛÝY]Ê  ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÑ[][IÌÎNË  ÌÍÜÔÛXÞR][M
BBPÛÛÛÝY]Ê ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÔÙ[XÝ   ÌÎNË ÌÍÚR][JBBPÛÛÛÙ[
    ÌÍÜÕ]K  ÌÎNÉÌÎNË  ÌÍÜÐÛÜÓ[YK   ÌÎNÞÑSTIÌÎNÊBBTÛY
L
B[[
I see now what i did wrong. The first example you gave was a look a like of me, but i used function in the standard way right from the help and try to adjust it. I was getting errors and errors and i couldn't get it to work. Sorry for my stupidity. :">

Share this post


Link to post
Share on other sites
SmOke_N

I see now what i did wrong. The first example you gave was a look a like of me, but i used function in the standard way right from the help and try to adjust it. I was getting errors and errors and i couldn't get it to work. Sorry for my stupidity. :">

Don't know if you can call that "stupidity" or misinterpretation, either way, I'm glad you understand maybe a tad more about the functions, then you did when you originally posted :D .

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Iznogoud

Don't know if you can call that "stupidity" or misinterpretation, either way, I'm glad you understand maybe a tad more about the functions, then you did when you originally posted :D .

Learn a bit more? lol i have learned alot more then i could wish before i started with AutoIT. Didn't know i could understand those things :D

Thx for your help, i will post my script later for people who replied before, wich are also interested.

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  

×