Help! How to uninstall existing app and install new one on Windows via Chef

I am new to Chef and I am looking for help from experts. I have doubts on Chef (Windows client side).
My client machines are installed with McAfee agent. Recently McAfee renamed the agent as Trellix agent. As a result, I need to uninstall Mcafee agent on the client machines and install Trellix agent. Both McAfee and Trellix agent's installer path, registry path etc are all same. In the add or remove programs. the new agent appear as Trellix agent instead of McAfee agent.

Now my doubt it, how can I add attributes and how to verify and remove McAfee agent.


In the attributes -> default.rb, I have created these in the attributes -> default.rb

default['trellix_cookbook]['agent']['package_name2'] = 'McAfee Agent'
default['trellix_cookbook']['agent']['package_name'] = 'Trellix Agent'

default['trellix_cookbook']['agent']['version'] = begin
node['packages']['Trellix Agent']['version']
rescue
nil
end

Not sure whether I can add like the one mentioned below in the attributes -> default.rb
default['trellix_cookbook']['agent']['version'] = begin node['packages']['McAfee Agent']['version']
rescue
nil
end


receipe -> default.rb

Adding a portion of default.rb file:

Here I need to check whether the client machine is having McAfee agent or Trellix agent. If McAfee agent is present, need to uninstall and install Trellix agent.

trellix_agent_installed = node['trellix_cookbook']['agent']['installed']
version_installed = node['trellix_cookbook']['agent']['version']
latest_agent_installed = (Gem::Version.new(version_installed) >= Gem::Version.new(node['trellix_cookbook']['agent']['package_version']))
if latest_agent_installed == true
# "latest agent installed and configured good"
else
include_recipe 'trellix_cookbook::repair'
end
else
#latest agent not installed"
include_recipe 'trellix_cookbook::agentuninstall'
include_recipe 'trellix_cookbook::agent'
end
else
#latest agent installed"
include_recipe 'trellix_cookbook::agent'
end

p.s sorry for the indentation, unnecessary bold texts and other stuffs. This is my first post so please ignore. I am trying to figure out how to properly compose and post here.