# Running a Windows .exe from Program Files

**URL:** <https://forum.ansible.com/t/running-a-windows-exe-from-program-files/23611>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [February 1, 2017, 2:18pm UTC](https://forum.ansible.com/t/running-a-windows-exe-from-program-files/23611 "2017-02-01T14:18:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [February 1, 2017, 2:18pm UTC](https://forum.ansible.com/t/running-a-windows-exe-from-program-files/23611/1 "2017-02-01T14:18:40Z")

</div>

Hi, all.

Another probably simple question that I need help with:

I need to run a program utility on several machines, as follows:

C:\Program Files\Kaspersky Lab\Network Agent\klmover.exe -address 172.16.1.1

I’ve tried running it using the raw command raw: c:\windows\system32\cmd.exe /C “C:\Program Files\Kaspersky Lab\Network Agent\klmover.exe -address 172.16.1.1”

I’ve tried several combinations of quotes around the command, and changing slashes/backslashes, but am not able to find a means to keep Ansible from complaining e.g. “”‘C:\Program’ is not recognized as an internal or external command". I think it has more to do with the spaces in the path. Anyway, I would appreciate your help.

Many thanks.

Dimitri

---

<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:** [February 3, 2017, 5:35am UTC](https://forum.ansible.com/t/running-a-windows-exe-from-program-files/23611/2 "2017-02-03T05:35:29Z")

</div>

Hi,

When using double quotes around windows paths, you usually have to use 2 backslashes for the path separator, so something like the following might work, although I think it might try and look for a program called ‘klmover.exe -address 172.16.1.1’ (instead of treating the -address 172.16.1.1 as arguments for the klmover.exe)

`raw: c:\windows\system32\cmd.exe /C "C:\\Program Files\\Kaspersky Lab\\Network Agent\\klmover.exe -address 172.16.1.1"`

You might not need to run via the cmd.exe though so perhaps try:

`raw: "C:\\Program Files\\Kaspersky Lab\\Network Agent\\klmover.exe" -address 171.16.1.1`

However, if you are using ansible 2.2 use win\_command (or win\_shell) modules instead of ‘raw’. Try something like this (which I think is easier to read than the others above).

`

win\_command: klmover -address 172.16.1.1  
args:  
chdir: C:\Program Files\Kaspersky Lab\Network Agent\

`

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [February 3, 2017, 6:52pm UTC](https://forum.ansible.com/t/running-a-windows-exe-from-program-files/23611/3 "2017-02-03T18:52:16Z")

</div>

Hi, Jon.

The path to the executable is actually C:\Program Files (x86)\Kaspersky Lab\NetworkAgent, My bad typing.

Since I am using version 2.2, I’ve tried win\_command, and get the following error:

fatal: [machine10]: FAILED! =\> {“changed”: false, “cmd”: “klmover -address 192.168.192.18”, “failed”: true, “msg”: “The system cannot find the file specified”, “rc”: 2}

The file klmover.exe IS in the specified directory. The command does have to be “Run as Administrator”, so I added become\_user: Administrator, but that didn’t help.

---

<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:** [February 5, 2017, 8:30am UTC](https://forum.ansible.com/t/running-a-windows-exe-from-program-files/23611/4 "2017-02-05T08:30:16Z")

</div>

Unfortunately become is not yet supported for windows hosts. I know there is work happening on this.

Would it be possible to switch things around and connect as Administrator, or a user with local admin permissions?

Jon
