Batch to Backup & Update

April 16, 2012 at 09:48:47
Specs: Windows 7

I need a batch file that to this:

Check two folders C:\Program and \\Update.

If the C:\Program\file.exe is equal to \\Update\file.exe, then it skips the update and starts C:\Program\file.exe.

If C:\Program\file.exe is older that \\Update\file.exe, then it copy or move C:\Program\file.exe to C:\Program\Backup\ and renames file.exe to file_date.exe, copy \\Update\file.exe to C:\Program\ and then starts C:\Program\file.exe.

I already have a batch file, but it doesn't check the two files, and I need to go to all the machines to force the update.

@echo off
echo ======= FILE UPDATE =======

pushd "%~dp0"

xcopy C:\Program\file.exe /Y "C:\Program\Backup"

rename "C:\Program\file.exe" file_%date%.exe

xcopy "\\Update\file.exe" /Y C:\Program\file.exe /D


@echo off

@echo off
start C:\Program\file.exe

Thank you in advance

See More: Batch to Backup & Update

Report •

April 24, 2012 at 17:39:26
Try this:

Echo n| comp C:\Program\file.exe "\\Update\file.exe"
If %errorlevel% EQU 0 GOTO SAME
Echo D| xcopy /y /q "\\Update\file.exe" C:\Program\file.exe
Echo File is the same
Echo File was updated

Report •
Related Solutions

Ask Question