# Windows; adding option to perform default action on a file after win\_copy / win\_template

**URL:** <https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589>\
**Category:** Ansible Developer\
**Tags:** windows\
**Created:** [June 24, 2015, 7:52am UTC](https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589 "2015-06-24T07:52:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 24, 2015, 7:52am UTC](https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589/1 "2015-06-24T07:52:51Z")

</div>

I’ve been making use of the win\_template module a bit and the thing I use it for most is to create a file of registry entries which I then import using raw like this:

raw: “reg.exe IMPORT {{ deployment\_files\_dir }}templated-registry-settings.reg”

I started thinking it might be nice if I added an option to win\_template that would merge the registry entries. Because its a ‘virtual module’ it would actually be a change to win\_copy module, but it would at least allow me to get rid of the ‘raw’.

The main objection I can think of to this would be that its not intuitive to look at the template module for the ability to manipulate the registry.

But then I started to think that maybe it would be better to have the option to call the default action on a file type (The default action is the one that appears in bold on the context menu when you right click on a file). It would be much more flexible than just having an option to merge the file contents into the registry, but I’m not sure if this would be a ‘too much rope’ type option.

Before I dig into this, I thought I’d ask if anyone thinks this is a good or bad idea or might have any other uses for it that I could put into examples.

Jon

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 24, 2015, 12:37pm UTC](https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589/2 "2015-06-24T12:37:29Z")

</div>

I don’t think importing into the registry is the correct thing for copy or template to do.

Why not create a new module for importing registry entries?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [June 24, 2015, 1:39pm UTC](https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589/3 "2015-06-24T13:39:09Z")

</div>

Yes a win\_registry\_merge module would be an option too.

I agree just having the option to import registry settings would be strange and fails the ‘do one thing well’ test. Invoking the default action though could be quite powerful - each file type can have a default action so for word documents, the default action is usually to open Word. Just don’t know if its too powerful.

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [June 24, 2015, 10:42pm UTC](https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589/4 "2015-06-24T22:42:54Z")

</div>

I dont think a simple “default action” would have much value without strong parameter support (maybe except in some very edgy edge cases). We would also need to handle what would happen after the file is invoked, manage processes and so on. I don’t think it’s a the right way to solve the problem.

However, manipulating registry entries is a very good idea - and one option for such a module could absolutely be to import a reg file.

-Trond

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 26, 2015, 1:13am UTC](https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589/5 "2015-06-26T01:13:01Z")

</div>

I agree with the other comments, this option should be it’s own module.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 15, 2015, 7:53am UTC](https://forum.ansible.com/t/windows-adding-option-to-perform-default-action-on-a-file-after-win-copy-win-template/18589/6 "2015-07-15T07:53:14Z")

</div>

Just to follow up on this, I’m working on a win\_regmerge module.

There is now a win\_reg\_edit module in latest devel extras, but if you have many registry settings to control I think having the option to merge in a reg file would still be useful.

Jon
