Cannot manually, or via Ansible, delete an installer executable installed by Ansible on Windows

  ansible, windows

I was able to install the 7-Zip utility on my Windows host via Ansible, putting the installer in c:tempz.exe. Here’s the task that installs it

- name: "Install {{ zip_product_id }} version {{ zip_version }}"
  win_package:
    path: "{{ remote_temp }}7z.exe"
    arguments: /S
    product_id: "{{ zip_product_id }}"
    state: present
  when: install

Now I want to uninstall it, including removing the c:tempz.exe file. However Ansible fails with

TASK [exa-prereqs : Delete c:temp] ********************************************
fatal: [10.227.xx.xx]: FAILED! => {"changed": false, "msg": "Failed to delete C:temp7z.exe: Access to the path 'C:temp7z.exe' is denied."}

and if I go to my Windows host and try to manually delete c:tempz.exe, I get a window that says

The action cannot be completed because the file is open in 7-Zip installer

How do I fix this? Task manager doesn’t show any task running. Sorry I’m not a Windows person.

Source: Windows Questions

LEAVE A COMMENT