WMIC: Run Batch Script Remotely
<p>I've been trying to get a Jenkins deploy job to work by running a batch script to do the install of an msi from the Jenkins build machine itself.  I've given the appropriate access rights, but still am not able to run the following command remotely, using <a href="https://msdn.microsoft.com/en-us/library/aa394531(v=vs.85).aspx" rel="nofollow noreferrer">WMIC</a></p>

<pre><code>wmic /node:myServerIp /user:"clientpc\my-user" /password:"my-password" process call create "D:\someDir\someOtherDir\test.bat"
</code></pre>

<p>The follow response from the above command:</p>

<pre><code>Executing (Win32_Process)-&gt;Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 9;
};
</code></pre>

<p>After some research, it looks like return value of '9' is 'Path not found' according to <a href="https://msdn.microsoft.com/en-us/library/aa389388(v=vs.85).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/aa389388(v=vs.85).aspx</a>, but I've verified that the path exists on the remote server.</p>

<p>The test.bat file that I'm trying to run is very simple, and should just write to a text file.</p>

<pre><code>@echo This is a test.&gt; test.txt
</code></pre>

<p>I've verified that both files exist on the server, and have granted 'EVERYONE' to the shared folder 'someDir'.</p>

<p>I have tried prefixing 'cmd.exe /c' to the path called:</p>

<pre><code>wmic /node:myServerIp /user:"clientpc\my-user" /password:"my-password" process call create "cmd.exe /c D:\someDir\someOtherDir\test.bat"
</code></pre>

<p>...for which I receive:</p>

<pre><code>Invalid Verb Switch.
</code></pre>

<p>I've verified that the user access is correct by providing a bad password, in which case permission is denied.</p>

<p><strong>EDIT:</strong>
Changed the path from <code>D:\someDir\someOtherDir\test.bat</code> to <code>D:\\someDir\\someOtherDir\\test.bat</code> but now receive the following error:</p>

<pre><code>ERROR:
Description = The RPC server is unavailable.
</code></pre>

<p><strong>EDIT 2:</strong>
Looks like the RPC user I was using was the cause for the error.  Still troubleshooting, but when I use my AD user, as opposed to the administrator I created to run this, I get the following AGAIN...</p>

<pre><code>Executing (Win32_Process)-&gt;Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 9;
};
</code></pre>