Check Installed program with batch script

batch-file, mcafee

I hope someone can help me with this.
Basically I want to add this to my login script. The batch script needs to check if McAfee agent5 is installed. If its not exit. If it is installed to run the force install form the network share.

I have used the location where agent5 gets installed. I am not sure if there is a way to check the installed version instead?

The reason I cannot do this from EPO is I cant downgrade? Agent5 blocks it, unfortunately.

This is what I have but it does not work? What am I doing wrong here?

IF EXIST "C:\Program Files (x86)\McAfee\Common Framework\CmdAgent.exe"GOTO :eof ELSE msiexec /i "\\192.168.55.125\McAfee Agent\FramePkg4.8.exe /install=agent /forceinstall" /s   :eof   END && EXIT

Best Solution

set filepath=%~f1set  file=%filepath:\=\\%wmic datafile where name^="%file%" get version|findstr /i /v /c:"version"

File paths must be \\ not \ as normal. The second line doubles backslashes.

Use a for loop to get in a variable.

for /f "skip=1" %A in ('wmic datafile where name^="C:\\windows\\notepad.exe" get version') do Echo %A