# Walking the registry, searching DisplayName, removing matching packages?

**URL:** <https://forum.ansible.com/t/walking-the-registry-searching-displayname-removing-matching-packages/27318>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [April 18, 2018, 10:51pm UTC](https://forum.ansible.com/t/walking-the-registry-searching-displayname-removing-matching-packages/27318 "2018-04-18T22:51:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bob/32/9260_2.png) [@bob](https://forum.ansible.com/u/bob)\
**Post date:** [April 18, 2018, 10:51pm UTC](https://forum.ansible.com/t/walking-the-registry-searching-displayname-removing-matching-packages/27318/1 "2018-04-18T22:51:03Z")

</div>

I’d like to remove all the “Slack Machine-Wide Installer” packages. My approach is listed below. I’m wondering if there’s an easier way to do this?

My approach.

Trying to use Ansible to uninstall packages; with a twist.

Control Panel shows this

[![](https://lh3.googleusercontent.com/-spATVpnfJng/WteyxCMQJzI/AAAAAAAAADs/lP2nEPG-9O0FFnsptEYsYWE3nexo8UP6wCLcBGAs/s320/altium17_int_celadonsystems_com.png)](https://lh3.googleusercontent.com/-spATVpnfJng/WteyxCMQJzI/AAAAAAAAADs/lP2nEPG-9O0FFnsptEYsYWE3nexo8UP6wCLcBGAs/s1600/altium17_int_celadonsystems_com.png)

Multiple versions of the Slack Machine-Wide Installer. Looking in the registry I find this key (as well as the other guids for the Slack Machine-Wide Installer):

HKEY\_LOCAL\_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall{81805212-8267-41AE-8F1E-979055EC5DF2}

[![](https://lh3.googleusercontent.com/-5h3IGbqpdgQ/WtezOAkG4gI/AAAAAAAAADw/GJmw58FGVqYfJHd8HDX7SjlhJsiKRDMQQCLcBGAs/s320/altium17_int_celadonsystems_com-2.png)](https://lh3.googleusercontent.com/-5h3IGbqpdgQ/WtezOAkG4gI/AAAAAAAAADw/GJmw58FGVqYfJHd8HDX7SjlhJsiKRDMQQCLcBGAs/s1600/altium17_int_celadonsystems_com-2.png)  
I’d like to walk the Uninstall registry key, searching the DisplayName for “Slack Machine-Wide Installer” and remove that package.

I can get the Uninstall registry using this task.

- name: get uninstall registry key  
win\_reg\_stat:  
path: HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall  
register: uninstall\_registry

The uninstall\_registry.sub\_keys contains the list I would like to query for the DisplayName, the below task lets me get the DisplayName of each key

- name: get properties of uninstall registry key  
win\_reg\_stat:  
path: HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall{{ item }}  
name: DisplayName  
register: display\_name  
with\_items:
- “{{ uninstall\_registry.sub\_keys }}”

After this I kind of stuck. How do I get just the DisplayName?

- debug:  
msg: “{{ item }}”  
with\_items:
- “{{ display\_name.results }}”

Displays a lot more information then I need. How do I get just the DisplayName?

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [April 18, 2018, 11:54pm UTC](https://forum.ansible.com/t/walking-the-registry-searching-displayname-removing-matching-packages/27318/2 "2018-04-18T23:54:23Z")

</div>

Look at the debug output and “walk” the structure to what you need, then put that into whatever needs it.

For example, when I create an AWS EC2 instance, the result variable contains a list of instances, with a table of attributes for each one. So to get to (say) the instance ID of the first instance in the list, I have to refer to results.instances[0].id

Your results variable is almost certainly structured, so look into that structure, figure out which bit you need, and refer to it using similar syntax.

Regards, K.
