1.

Solve : Need a Batchscript that will check the version of a file-and Uninstall if exist?

Answer»

Basically i need a batch script that will first check if a particular file version exists., And if it does, it will uninstall it. If it does'nt exist, than it will do nothing and exit.

in this case its the file named "BmaSearch.exe"




Here is a work in progress script that i put together. I just need help with the check version PART of it.


"@echo off

REM check if BARRACUDA Add-In is already installed
if exist "C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
) else (

if exist "C:\Program Files\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
))




:UNINSTALL

REM UINSTALL ADDON
echo UnInstalling
msiexec /x \\qpaynet.local\sysvol\QpayNet.local\Policies\{B7D55D1D-7D20-46EB-92F9-FEB42BABC41E}\Machine\Applications\BmaOutlookAddIn-3.6.20.0_x86.msi /quiet

exit"


Please help

thanksNot seeing what you need help with. The syntax of all your commands look correct.@echo off

REM check if Barracuda Add-In is already installed
if exist "C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
) else (

if exist "C:\Program Files\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
)}

EXIT
REM EXIT or else you will go to UNINSTALL whether or not the file exists!

:UNINSTALL

REM UINSTALL ADDON
echo UnInstalling
msiexec /x \\qpaynet.local\sysvol\QpayNet.local\Policies\{B7D55D1D-7D20-46EB-92F9-FEB42BABC41E}\Machine\Applications\BmaOutlookAddIn-3.6.20.0_x86.msi /quiet

REM You don't need this
REM exit

You could do it in 5 lines of code:

@echo off
set installed=NO
if exist "C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" set installed=YES
if exist "C:\Program Files\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" set installed=YES
if %installed%=YES echo UnInstalling & msiexec /x \\qpaynet.local\sysvol\QpayNet.local\Policies\{B7D55D1D-7D20-46EB-92F9-FEB42BABC41E}\Machine\Applications\BmaOutlookAddIn-3.6.20.0_x86.msi /quiet
are you guys not reading the subject of this thread?


i clearly stated that i am looking for a way to have the script CHECK THE VERSION OF THE BMASEARCH.EXE file and depending at if it matches 3.6.20.0 then uninstall.

what i have there in the script so far is simply uninstall if the .exe exists period. This is not what i want it to do. so please

is there any way to set a condition where it will check the version of the file???Quote from: jblanc03 on September 29, 2015, 07:16:21 AM

are you guys not reading the subject of this thread?
We apologise for the poor service. You can claim a full refund of your joining fee, and also of the fee you paid for asking your question. Please have your payment reference number ready when making the claim.
nvm

You can use powershell to get the version.

Code: [Select]D:\>for /f "delims=" %%p in ('powershell -Command "(Get-Item C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe).VersionInfo.ProductVersion"') do set version=%%p

the Product Version of the executable will be saved in %version% and you can compare it.
Or WMIC
Code: [Select]for /f "tokens=2 delims=," %%G in ('wmic datafile where "Name='C:\\Windows\\System32\\cmd.exe'" get Version /format:csv') do set cmdver=%%GThis assumes the executable was compiled with version information. Quote from: Salmon Trout on September 29, 2015, 11:58:56 AM
This assumes the executable was compiled with version information.
Well the information provided has been so clear on how we should solve this problem. We are all just grasping at straws. Not sure where else we would get the version information of the install. I guess it could be in the registry but I do not have this program installed to check if that is the case or not.Quote from: Squashman on September 29, 2015, 12:04:27 PM
I guess it could be in the registry but I do not have this program installed to check if that is the case or not.
This is one of the (considerable) stumbling blocks in our path.
Quote from: Squashman on September 29, 2015, 12:04:27 PM
I do not have this program installed to check if that is the case or not.
I would be surprised if you did. Barracuda Message Archivers are a range of hardware appliances that sit on a corporate network and cost $2,000 for the Model 150 (max 150 users) via the Model 450 $10,000 dollars (max 1,000 users) to the model 1050 "request a quote" (max 18,000 users). All models require a mandatory yearly update subscription costing between hundreds and tens of thousands of dollars. So not home stuff. The Outlook add-in needs to have the same major version number as the appliance firmware. I am not an expert, but it seems from a cursory look at the maker's help pages that users with a valid ongoing subscription should be able to get help to keep their deployed software up to DATE. A big element of the publicity for these products is comprehensive security and suitability for use in situations where compliance with statutory or regulatory requirements is important. Audit trails. Pro stuff. So why is a "Barracuda Message Archiver Adminstrator" asking this on here? He was LIKELY promoted to a position he's ill suited for...Only thing worse than doing somebody's homework is doing their job...


Discussion

No Comment Found