Check EXE version in a batch file and if need be replace with another

I want to replace a file tswpfwrp.exe in Windows\System32 folder if it is an older version then the one I am replacing it with, otherwise, I don't want the batch file to run.

Below is an example of what I am trying to achieve, however, I don't know much about batchfile creation so the below example is not functional. Please help me create an effective batch file:

IF EXIST "C:\WINDOWS\system32\tswpfwrp.exe VER 3.0.6920.1201" goto lable1
IF NOT EXIST "C:\WINDOWS\system32\tswpfwrp.exe VER 3.0.6920.1201" goto lable2

echo Current Version exists
goto exit

copy \\ourdomain\dfs\SoftwareInstall\dotNetFramework\tswpfwrp >> c:\C:\WINDOWS\system32\

goto exit

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

XCOPY /d will only copy if the file is newer than the destination.

xcopy /d /y \\ourdomain\dfs\SoftwareInstall\dotNetFramework\tswpfwrp C:\WINDOWS\system32\*.*

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
With a batch file I do not think this is possible without some other third party utility, however you can accomplish this with vbscript like

Set objFSO = CreateObject("Scripting.FileSystemObject")
Wscript.Echo objFSO.GetFileVersion("c:\windows\system32\notepad.exe")

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.