Copy a non exe File to a Remote Machine

sriram picture sriram · Apr 12, 2012 · Viewed 58.2k times · Source

I used PsExec to copy and run an exe file in a remote machine. I also want to copy a xml file to remote machine. I am able to do this way

PsExec.exe -d -c \\someserver  c:\somefile.xml 

The above command throws error saying system cannot find the file specified but adds the xml file to remote server.
Do u know any better way of copying files to remote server.
Is there any PsTool available for that?
Or an option in PsExec ?

Edit: (Answer) I found out that using Powershell we can copy file to remote machines and it worked.

Answer

Marco picture Marco · Apr 12, 2012

As you can read from psexec help

-c: Copy the specified program to the remote system for execution. If you omit this option the application must be in the system path on the remote system.

So your xml file is copied on remote sys/USER:[domainname]username]tem and executed, this gives you the error.
If your xml is part of an application you have to run in remote computer, one solution is compress the app with all necessary files in a self-extracting EXE that runs main command when extracted.

If you just have to copy a file, why don't you use a simple script that maps remote folder and then copies file? Something like:

NET USE \\computername\sharename password /USER:[domainname\]username
xcopy .....
NET USE \\computername\sharename /DELETE