0

I need to copy some files locally, on a remote server (Let's say it's in New York). That is to say, the files are already on the server, and I need to make a copy in the same frolder on that server. There's a batch script on the server, which uses RoboCopy, to copy the files.

I use the "Call" command in a local batch script (let's say it's in London), to execute the remote batch script, and pass it parameters, such as source and destination paths.

That all works perfectly, except for the fact that all the processes are taking place on the local (London) server, instead of the remote one, so the copy process takes forever - Robocopy is running in London, trying to copy files from New York to New York. The whole idea of calling one batch script from another, was for the processes to execute on the remote server.

I know I could use PSExec, but as much as I love SysInternals, I'm (ideally) trying to avoid using anything that's not already part of Windows.

This is all happening on Windows Server 2016, by the way. No firewall or networking issues to worry about, either.

I'm also trying to stick to batch scripts, as this was already set-up and working perfectly, and the only thing that changed was the need to run the processes remotely. So I don't want to have to re-write the whole thing from scratch, in PowerShell or whatever.

Does anybody know how to achieve that?

There's a bit more to the scripts than just copying files, but I don't want to go overboard with information.

Thanks.

6
  • 1
    Have you tried using cmd /k?
    – JW0914
    Commented Mar 31, 2021 at 21:07
  • I tried with cmd /c, and that didn't help, so I'm thinking cmd /k would be no different (except for how it exits)? Commented Apr 6, 2021 at 17:36
  • /c and /k do two completely different things - /c effectively uses a new terminal space for every command, whereas /k uses the same terminal space, often being used to maintain variables across multiple user-input commands (e.g. a script is run with /k that sets variables, and once the script exits, the same terminal space is maintained, allowing the variables set by the script to still be used - an example of this can be seen when using the ADK and executing within PowerShell "%ProgramFiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\DandISetEnv.bat")
    – JW0914
    Commented Apr 7, 2021 at 12:31
  • Hey, thanks very much for the suggestions, and that's useful to know. Commented Apr 8, 2021 at 12:35
  • I gave cmd /K a shot, and unfortunately, it did the same thing. RoboCopy is still running on my machine, rather than the remote server. Commented Apr 8, 2021 at 12:36

0

You must log in to answer this question.

Browse other questions tagged .