# Remote Windows batch script says completed successful, but did not work

**URL:** <https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321>\
**Category:** Ansible Project\
**Tags:** windows, ubuntu\
**Created:** [January 22, 2016, 6:02pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321 "2016-01-22T18:02:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Levis](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joe\_Levis](https://forum.ansible.com/u/Joe_Levis)\
**Post date:** [January 22, 2016, 6:02pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/1 "2016-01-22T18:02:17Z")

</div>

I’m running Ansible 2.0.0.2 on a Ubuntu 14.04 Control Machine. I’m using the script module in my Playbook to run a batch file, which executes a PowerShell script to create a Windows share (Windows Server 2012 R2). The Playbook completes successfully:

ok=3 changed=1 unreachable=0 failed=0

However, the share is not created.

**I confirmed it works if I run the same batch file manually on the Windows server.**

**Here’s my Playbook:**

- name: Create shares

script: files/ui/create-shares.bat

tags: create-shares

**Here’s the batch script:**

@ECHO OFF

SET PowerShellScriptPath=C:\create-shares.ps1

PowerShell -NoProfile -ExecutionPolicy Bypass -Command “& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File “”%PowerShellScriptPath%”“’ -Verb RunAs}”;

**Here’s the PowerShell script:**

New-SmbShare -Name test -Path C:\test -FullAccess domain\user

Any ideas?

---

<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:** [January 22, 2016, 6:40pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/2 "2016-01-22T18:40:25Z")

</div>

My guess would be you need to run as a privileged user, such as Administrator.

There is a PR for a win\_share module which sounds like just what you are after though.

I will dig out the link.

Jon

---

<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:** [January 22, 2016, 6:40pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/3 "2016-01-22T18:40:26Z")

</div>

My guess would be you need to run as a privileged user, such as Administrator.

There is a PR for a win\_share module which sounds like just what you are after though.

I will dig out the link.

Jon

---

<div class="post-metadata">

**Author:** ![Joe\_Levis](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joe\_Levis](https://forum.ansible.com/u/Joe_Levis)\
**Post date:** [January 22, 2016, 6:43pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/4 "2016-01-22T18:43:40Z")

</div>

Hi Jon,

Thanks for the quick reply.

I’m authenticating to the Windows server using kerberos and the user is an Administrator on the server.

-Joe

---

<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:** [January 22, 2016, 6:45pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/5 "2016-01-22T18:45:33Z")

</div>

It's here

[https://github.com/ansible/ansible-modules-extras/pull/1213](https://github.com/ansible/ansible-modules-extras/pull/1213)

Would be great if you could test it as it would get it one step closer to being included in Ansible.

Jon

---

<div class="post-metadata">

**Author:** ![Joe\_Levis](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joe\_Levis](https://forum.ansible.com/u/Joe_Levis)\
**Post date:** [January 22, 2016, 7:12pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/6 "2016-01-22T19:12:30Z")

</div>

Thanks Jon.

I’ll give it a try and post back.

-Joe

---

<div class="post-metadata">

**Author:** ![Joe\_Levis](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joe\_Levis](https://forum.ansible.com/u/Joe_Levis)\
**Post date:** [January 22, 2016, 8:02pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/7 "2016-01-22T20:02:40Z")

</div>

Yes! That module works for me!

I’ve approved the Pull Request in GitHub as well.

Thanks,  
-Joe

---

<div class="post-metadata">

**Author:** ![Joe\_Levis](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joe\_Levis](https://forum.ansible.com/u/Joe_Levis)\
**Post date:** [January 22, 2016, 10:44pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/8 "2016-01-22T22:44:47Z")

</div>

It looks like the PR for the win\_share module is ready to be merged - do you know when that would actually be merged into the devel branch?

Also, do you know where my modules are located if I’ve installed Ansible using the apt-get repo? The ansible.cfg on my Ubuntu machine has a commented-out library location:

$ cat /etc/ansible/ansible.cfg | grep library

#library = /usr/share/my\_modules/

And /usr/share/my\_modules is empty.

---

<div class="post-metadata">

**Author:** ![Joe\_Levis](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@Joe\_Levis](https://forum.ansible.com/u/Joe_Levis)\
**Post date:** [January 22, 2016, 11:15pm UTC](https://forum.ansible.com/t/remote-windows-batch-script-says-completed-successful-but-did-not-work/20321/9 "2016-01-22T23:15:33Z")

</div>

Nervermind. Figured out how to add custom\_modules into roles:  
[http://docs.ansible.com/ansible/playbooks\_roles.html](http://docs.ansible.com/ansible/playbooks_roles.html)

Thanks again.

-Joe
