# win\_file module - won't delete file when special characters in path

**URL:** <https://forum.ansible.com/t/win-file-module-wont-delete-file-when-special-characters-in-path/20361>\
**Category:** Ansible Developer\
**Tags:** windows\
**Created:** [January 27, 2016, 4:30pm UTC](https://forum.ansible.com/t/win-file-module-wont-delete-file-when-special-characters-in-path/20361 "2016-01-27T16:30:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricky\_Basra](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@Ricky\_Basra](https://forum.ansible.com/u/Ricky_Basra)\
**Post date:** [January 27, 2016, 4:30pm UTC](https://forum.ansible.com/t/win-file-module-wont-delete-file-when-special-characters-in-path/20361/1 "2016-01-27T16:30:34Z")

</div>

##### Issue Type:- Bug Report

Ansible Version:

ansible 2.0.0.1

Ansible Configuration:

No change

Environment:

##### Running from GNU Linux and managing Windows 2012 server

Summary:

Trying to delete a file on the server using the win\_file fails when name contains special characters

c:/temp/[test].xml

Steps To Reproduce:

Create file c:/temp/[test].txt

use win\_file module to try and delete it

win\_file: path=‘c:/temp/`[test`].txt’ state=absent

Note: 2 backticks used escape the square brackets

Expected Results:

To delete file

Actual Results:

Does not delete file!

Possible fix:

I added the following line which fixed the issue. Using get-item info to delete the file did not work. Using $path instead did.

PS C:\Users\Administrator\> $path

C:/temp/`[test`].txt

PS C:\Users\Administrator\> Get-Item $path

Directory: C:\temp

Mode LastWriteTime Length Name

* * *

-a— 1/27/2016 1:58 PM 0 [test].txt

---

<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:** [January 28, 2016, 3:45pm UTC](https://forum.ansible.com/t/win-file-module-wont-delete-file-when-special-characters-in-path/20361/2 "2016-01-28T15:45:43Z")

</div>

Well done for finding this and the solution for it.

Would you be able to create a pull request to fix it?

It would be really good if you could also add a test into the tests in ansible/test/integration/ so we can make sure it stays fixed as other changes are made too.

Jon
