Impersonating User on "Run DOS Command" fails

I'm trying to copy the build output to a unc path on a different server which requires different credentials to those to which I'm executing the build in.  When I run the task as "Default user" it runs, but fails with an "access denied" error, which is expected.  When I set the "execution properties" to run the action as a different user on a different domain, it fails with the following error:

Executing external process: C:\WINDOWS\system32\cmd.exe
Starting Directory: c:\
Parameters: /c copy "" ""
Impersonating User: \

Output from C:\WINDOWS\system32\cmd.exe
Failed to execute program C:\WINDOWS\system32\cmd.exe /c copy "" ""
 as user \. Error : The stub received bad data

If I try to run XCOPY using the "Run Program" action with the user details, I get exactly the same error.

Any help would be appreciated.

Cheers,

ash.

 

Hi Ash,

I’m assuming you’re using the Run Process As option so that you have the right security to access the UNC path? If this is the case, then why not use the Map Network Drive action to map the UNC share under the correct user account?

Regards,
Paul.

Hi Paul,
Thanks for the quick response. This workaround does allow me to achieve what I was aiming for.

cheers,
ash.

Hi Ash,

That’s great Paul.

Old thread but I was just having the same issue,
Xcopying from any path to a unc path as another user gave me the usual Failed to copy…Error : The stub received bad data

If I took the line from the output and pasted it in a command prompt, it ran perfectly.

Unfortunately I could not use the mapped drive workaround as I have several labs composed of VMs that I need to push to.

What I ended up doing is run finalbuilder and fbcmd as the user I wanted to impersonate directly instead of doing it per action, then all your actions will run in that security context.

There’s still an issue in FB I believe but I can continue with the above.

Thanks,