# Run a .json file via command line

**URL:** <https://forum.ansible.com/t/run-a-json-file-via-command-line/26368>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [December 21, 2017, 10:18pm UTC](https://forum.ansible.com/t/run-a-json-file-via-command-line/26368 "2017-12-21T22:18:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpescatore](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lpescatore](https://forum.ansible.com/u/lpescatore)\
**Post date:** [December 21, 2017, 10:18pm UTC](https://forum.ansible.com/t/run-a-json-file-via-command-line/26368/1 "2017-12-21T22:18:30Z")

</div>

Hi, I want to start a json (gcloud) file via command line (win 10 pc) in ansible.

What I am trying now is:

name: run command

win\_command: C:\Windows\System32\cmd.exe gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json

All that happens is the command prompt opens.

When I manually paste “gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json” into a command prompt it works.

Thus I just think the syntax is incorrect. Any idea on the proper syntax to run something through cmd?

I have also tried

win\_command: ‘C:\Windows\System32\cmd.exe “gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json”’

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [December 22, 2017, 12:24am UTC](https://forum.ansible.com/t/run-a-json-file-via-command-line/26368/2 "2017-12-22T00:24:08Z")

</div>

You can try just running the gcloud executable by itself to make things simpler like so

> - win\_command: gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json

This should work unless that relies on any shell ism’s which are not available in win\_command. Otherwise you have 2 other options if you really need to run it under command prompt

`

- name: run it under win\_shell and specify it to run under the cmd shell  
win\_shell: gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json  
args:  
executable: cmd.exe

- name: run it under win\_command by creating a new cmd shell and executing the command  
win\_command: cmd.exe /c gcloud auth activate-service-account --key-file=C:\Users\user\Desktop\foo.json  
`

The last example is close to what you were trying to do but to run a command in cmd you must pass the /c argument telling it what command to actually run.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![lpescatore](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lpescatore](https://forum.ansible.com/u/lpescatore)\
**Post date:** [December 22, 2017, 10:14pm UTC](https://forum.ansible.com/t/run-a-json-file-via-command-line/26368/3 "2017-12-22T22:14:10Z")

</div>

Thank you sir, the last command worked, though win\_shell did not.  
Follow up: what is the switch to run cmd.exe AS ADMINISTRATOR?

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [December 22, 2017, 11:07pm UTC](https://forum.ansible.com/t/run-a-json-file-via-command-line/26368/4 "2017-12-22T23:07:56Z")

</div>

A WinRM command always runs with the highest privileges possible, so under and admin it should run as an admin. You can check it out by running ‘whoami /groups’ in win\_command, the mandatory label at the bottom tells you what level of privileges you are running with.

- medium is a standard user without admin privileges  
- high is with admin privileges  
- system is running under a well know service account and is similar to high
