Avatar of José Perez
José Perez
Flag for Chile asked on

Copying files across 2 remote servers

Hi,
amongst all the daily activities I have, there 2 that really takes a lot of time because I have to do it manually :(

Case 1:
I have 1 executable file, "myApp.exe" that needs to be copied  (and overwrite existing one) to a second server:
from \\SERVER1\anyFolder\myApp.exe to \\SERVER2\anyFolder\myApp.exe
Issue:
I am trying to do it automatically via CMD script using "runas" command but it is not working transparently because it ask me for password, eache time It connects to a different server (14th servers).

"run.bat" file runs:
runas /netonly /user:AMERICAS\myUserName RemoteServer01.bat

"RemoteServer01.bat" file runs:
Copy \\RemoteServer01.americas.local\e$\Tools\RMTool\RMTool.exe \\RemoteServer02.americas.local\e$\Tools\RMTool\RMTool.exe  /B /Z /Y

Open in new window


Case 2:
This one is done via RDP but I would like to do it via cmd if possible:
First step, connect to \\SERVER1\d$\ProductFolder
Second step, using Windows  "Right click / Compress to zipped folder" compress to zip "ProductFolder"
Third, rename resulting zip file adding (manually) current date as a prefix, example of resulting file: "2017-05-05-Oracle.zip"
Fourth step, Move the resulting zip file to \\SERVER1\e$\Backup folder

Thanks a lot!
Shell ScriptingMicrosoft DOSWindows OS

Avatar of undefined
Last Comment
Wayne88

8/22/2022 - Mon
SOLUTION
NVIT

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Wayne88

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
NVIT

For Case 2, I can help you write a CMD if you like. A cmd solution requires a 3rd party tool, like 7-zip or similar.

If 3rd party is not an option for you, you can use powershell, assuming you have versions 3 or 4 with Net 4.5 (or greater). Or powershell 5, which has built-in zip commands.

On https://ss64.com/ps/zip.html, there is a powershell routine New-Zipfile that does this. I haven't tested this so can't confirm it.
José Perez

ASKER
@NVIT
Case 1: Interesting, it makes sense. I'll try it ;)

Case 2: CMD would be excellent! But you must consider the following:
In the servers side I cannt install/copy anything alese. If the 3rd party tool you mention can be coied to my computer and from here run the CMD commands, that'll be very good option.

@Wayne88
I've seen that Powersheel  is something like CMD but how can I know/test if this supports what you're recommending?
Wayne88

"@Wayne88
I've seen that Powersheel  is something like CMD but how can I know/test if this supports what you're recommending?"

Hi Jose, how do you mean?  The test should very easy because all the program does is copy files/folders.  That's all it does.  If you like to execute a *.bat or *.exe you still need to call this program before or after the file copy.  For example, you can call a batch file after the copy finish to ZIP the folder/file that was copied.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
NVIT

@Jose

> Case 2: ...If the 3rd party tool you mention can be coied to my computer and from here run the CMD commands, that'll be very good option.
That should work. I presume your station and the servers are on same domain or workgroup?
José Perez

ASKER
@NVIT: Yes, same domain.
NVIT

Jose,

Do you still need help with this?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Wayne88

"@Wayne88
I've seen that Powersheel  is something like CMD but how can I know/test if this supports what you're recommending?"

Hi Jose, I am not understanding this statement because I didn't mention Powershell.  Also, you mentioned that you wanted to run a batch file not powershell and the dirsync program I mentioned can run the batch file as required.
José Perez

ASKER
Best answer was @Wayne88 but @NVIT's answer also help me a lot.
Wayne88

Thanks Jose, glad to help. Cheers!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck