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).
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
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.
> 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?
"@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.
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.