Boycotts can only be effective if they are not clouded by political and economical interests for the one who does want to punish, and quite often this is the case. A boycott that appears to have been effective was the South-Africa boycott which came as a protest against the apartheid regime. Only a few companies (most notably Shell) still did business with South-Africa in the time.
Other boycotts can indeed be lesser effective. There has been some will to boycott Russia for many reasons, and now aside from the question if Russia should be punished or not, as that is a discussion not relevant for this particular question, there are obstacles in the boycott itself. Russia is one of the biggest gas producers of Europe. Some countries are completely dependent on Russia for their energy as a result. A boycott will therefore only backfire on them. One of the reasons behind sustainable energy is also to be less dependent on other countries... It's more than just climate change.
Now, Trump tries to boycott Iran, but he knows his boycott won't work as Europe wants to keep the nuclear deal up, so what did he do... Ban all European countries to do business with the U.S. if they are in any kind of way related to Iran. This is by the way a violation of international treaties regarding trade in general, not to mention that Trump does this way dictate the law to countries who are not part of the U.S. This means that he may be able to get away with this on the short term, but on the long term this won't sustain, regardless if Biden wins the elections or not and goes a different way on this particular matter or not. Also Iran is used to be under pressure from the entire world and has a few powerful allies. Boycotts can only be effective if the whole world is in agreement, like in the apartheid case, but as soon as interests of other powerful players, like in the cases of Russia and Iran, things will turn out differently.
When it comes to boycotts against companies, then basically the same applies. I will not do business myself anymore with some companies who swindled me. But I do know that other people will still go there. So that company won't care. When the group gets larger, then they can have a problem.
Boycotts require unification from the boycotting parties to have any effect. Also some parties can really get in trouble due to a boycott, others may not. Every case is different. Sometimes a boycott fail and make the boycotted party only more fanatic...