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.
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)
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).
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.