• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5332
  • Last Modified:

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

:LABLE1
echo Current Version exists
pause
goto exit

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

echo INSTALLING DOTNET FRAMEWORK UPDATE.
Pause
goto exit

:EXIT
0
SCRLPB
Asked:
SCRLPB
1 Solution
 
AmazingTechCommented:
XCOPY /d will only copy if the file is newer than the destination.

xcopy /d /y \\ourdomain\dfs\SoftwareInstall\dotNetFramework\tswpfwrp C:\WINDOWS\system32\*.*
0
 
CoyotesITCommented:
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")

0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now