Hi,
TL;DR - need the “run as administrator” to be automated.
I have tried and tried to get a bat file to run as administrator on a windows box.
What it is supposed to do is chmod a file in cygwin.
Manually, if i right click and run as administrator, it works fine.
If I run my play (below), it gives no error, but does not do anything (i run the bat manually, not as admin, and get an error saying permission denied, so it’s def a permissions issue that running as admin solves).
I tried win_ps_exec, but I get an error there saying psexec.exe not found.
What can I do to fix?
- name: copy chmod batch file over
win_copy:
src: /ansible/batch/chmod.bat
dest: C:\TEMP\chmod.bat
- name: copy chmod sh file over
win_copy:
src: /ansible/batch/chmod.sh
dest: C:\TEMP\chmod.sh
- name: Run Batch File
win_command: C:\TEMP\chmod.bat
Contents of bat:
C:\cygwin\bin\mintty.exe C:\TEMP\chmod.sh
Contents of sh:
chmod 660 /etc/rsyncd.secrets