Can PSEXEC be used to copy a local file to a remote location?

I am trying to write a simple batch file which will use HP's online ILO configuration utility (hponcfg.exe) to add an administrative user to all ILO's in our organization.  

To do this, I need to take a .xml file on one server and copy it to the server I am running psexec on.  I then run another psexec command which uses hponcfg to add the user to the ilo.  The reason I want to use psexec to do the file copy instead of just copying the file outright is because psexec has the "@file" feature which allows you to fee a .txt file with your server list to it.  Using this will allow me to to add the user to all ILO's at once in my organization.  If I use copy, I need to copy this file for each server and I would like to avoid that if possible.

I'm trying to take ilo_update.xml on a server called insightmgr and copy it to the M: drive on a server called citrix-xp02.  Later I run another psexec command which uses hponcfg to reference the ilo_update.xml file, which works flawlessly.

below is the psexec command and error that is returning.  Anyone know what I'm doing wrong?  When I run the command locally on the citrix server it works like a charm!

psexec \\citrix-xp02 -u "domain\user" -p "password" "cmd.exe copy \\insightmgr\c$\downloads\ilo_scripts\ilo_update.xml M:"

PsExec v1.94 - Execute processes remotely
Copyright (C) 2001-2008 Mark Russinovich
Sysinternals -

Starting cmd.exe copy \\insightmgr\c$\downloads\ilo_scripts\ilo_update.xml M: on

PsExec could not start cmd.exe copy \\insightmgr\c$\downloads\ilo_scripts\ilo_up
date.xml M: on citrix-xp02:
The system cannot find the path specified.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
If you have a list of server names in a text file then just use a batch file to do it with a for command:

for /f %%a in (servers.txt) do xcopy /d/y c:\sourcfile.xml \\%%a\share\path

i.e. for each server listed, one per line, on servers.txt the xcopy command will be run from c:\sourcfile.xml to \\servername\share\path

I imagine the problems you are having could be to do with the m: being a network drive or the UNC not being available to the process ran from the other machine.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
If you raise any other batch file issues can I suggest raising them in the MSDOS T/A as there are more experts there
mihalakjAuthor Commented:
Great Answer, just one comment, need to add a space between the "/d" and "/y" in your code.  see below.

for /f %%a in (servers.txt) do xcopy /d /y c:\sourcfile.xml \\%%a\share\path

I guess I need to work on my windows batch scripting, but I can use that line alot! THANKS!
Steve KnightIT ConsultancyCommented:
Sorry about the missing space, was typed quickly from memory. Yes for is REALLy useful.  Have a look at for /?, set /? and if /? for loads of hidden usefulness that doesn't get used enough.

If you get any other batch file question post them in MSDOS area (as the main entry) as the first entry you choose is where the points go... pretty well wasted for me at least in this one.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.