• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 17630
  • Last Modified:

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 - www.sysinternals.com

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.
  • 3
1 Solution
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.


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.



Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now