user-1: How can I prevent harmful thoughts and intentions from coming into my head?
How can I remove them if they do come into my head?
Even if I try to forget about them, I will still remember it. So how can I forget about them and never remember it?

user19480: Stop listening to them. Stop recalling them. Stop rolling them over in your mind.
If you stop doing all of that, they won’t draw your attention away from what is actually happening, they won’t bother you, or stress you out, and you won’t remember them because they will just evaporate as if they were never there.
You do all that by earnestly practicing meditation with the guidance of a qualified teacher—and preferably not a secular teacher of mindfulness because of their serious limitations.
Do that and you can become liberated from all the troubles of an uncontrolled mind.
Update:

When you attempt to suppress emotions, thoughts, or perceptions—when you forcefully try to control them—you are chaining yourself to them. You should never try to suppress anything that arises during meditation, nor during your mindful moments during your daily life.
Instead, you must train your mind not to wander distractedly along with your emotions, or thoughts, or all the myriad of perceptions that arise throughout your day and practice sessions. You train your mind to remain with that which you are mindfully doing. In the case of meditation, your mind remains in the practice, whatever it is, regardless of whatever happens.
Of course, there are times in your normal daily life when, not having fully trained your mind, you may be distracted by some, or all, of these things and you may feel the need to try to suppress them—but remember that when you engage with them in this way you are shackling yourself to them by doing so!
Trying to suppress emotions, thoughts, and perceptions is at best nothing more than a quick fix that will return frequently to haunt you in your practice, and even worse, trying to do so is a sure way to become disenchanted with meditation.
The better way, and the one that a trained mind provides you the faculty to follow, is that you are never more than momentarily disturbed because your mind doesn’t wander, doesn’t get distracted, is totally focused as you intend to be, and is never straining—you are at ease, like an unmovable mountain. The mind thus finds great ease and calm in all that it does, and easily lets thoughts, emotions, and perceptions pass without engaging with them.
In between these two—a mind not yet trained, and one that is—you should strive to notice what is arising at all times. When distracting thoughts arise you should note them and then redirect your mind back to your desired center of focus. And it should be the same for emotions, as well as distracting perceptions.


user13694: This is based mainly on my experience and in my imperfect understanding of the Dhamma. So, take this with a grain of salt.
I think it's useful to define "control". If you understand 'control' as the act of making things go according to your desires, then such notion can be deceiving and illusory, if not nuanced.
Things arise and cease according presence of their required conditions and causes; if those don't come together in the requiered way, things will not arise.
Knowing the above one can should reflect on the possible way one acts on the world or in one's "own" mind: an action is the intervention of the present state of things of the world/mind, and which condition to come to be is intention. The result of the action will go according to your expectations if the action affects the state of things in the necessary way as to successfully bring the conditions of the desired things to come together in the necessary way it requires.
Action is the execution of changes in the state of things, preceded by an intention. The three main ways in which we can act is through thoughts (modifying the state of the mind), words (modifying other's state of mind) and bodily acts (modifying the physical world).
In order to "control" you mind, one should know what the desired state of things is, i.e. how you expect the mind to be after you have exerted "your" control and will. Once you know that, what should be done is to influence the state of things to bring the necessary conditions to the state of things desired to arise. To "control" the mind, you need to keep track of the state of the mind (feelings, intentions, perceptions, etc.) in every present context, and based on the context perceived, you can decide what to do with it: if the things detected are unwholesome, you can let it go or not feed it; of it's wholesome, you can keep it and develop it. The degree of success will depend on your familiarity and amount of practice with paying attention to whatever presents in the mind, and on the correct identification and effectiveness in the influence of the factors needed to lead the mind into the desired state of things.
Finally, the Buddha offers us a definition, categorization and explanation of what's wholesome and what's not: that is contained in the development of Right View
Kind regards!

user43: The way my teachers taught me about this, it's not about "controlling your mind", that's the wrong way to look at it. It is about letting go of attachments which create those disturbances. Once you clearly see your attachments and their roots (prejudices, stereotypes, traumas) then resolving them is a matter of focus and firm intent. Once attachments are out, the disturbing thoughts still by themselves.

user19837: Pacifying the mind
Huike said to Bodhidharma, "My mind is anxious. Please pacify it."
Bodhidharma replied, "Bring me your mind, and I will pacify it."
Huike said, "Although I've sought it, I cannot find it."
"There," Bodhidharma replied, "I have pacified your mind."
https://en.wikipedia.org/wiki/Dazu_Huike#Pacifying_the_mind
There's not much more to say. I'll leave you with some thoughts that may help you to realise that what you're experiencing is really not a big deal.
Thoughts come. If you try to control them, they will become stubborn and call more loudly for attention. You need to deal with it, but in a more relaxed way. Look at the thought without judgement. Accept its coming, its stay, and its going. You are just a spectator, not involved.
Still you are human and your greatest strength is love. Let the thought not be unwanted and wither away. Treasure it for its message; it came to you at this time for a reason that may not lie on the surface. It is calling you, and only you can understand. That is the treasure. With this enrichment you can bid the thought farewell.

user19481: Who cares if they come or go?  They aren’t you.  Do you get upset when you breath in?  Or when you put a hat on?  Why frustrate yourself with externalities?  You have no more control of your thoughts than the sky controls the number of clouds.  Does the sky worry itself on overcast days?
The second patriarch came to Bodhidharma’s cave.  “Master, my mind gives me no rest.  How can I pacify it?” “Show me your mind and I will pacify it for you,” the western barbarian replied.
There is no mind.  There is no pacification.

user8157: Practise what is explained in MN 19.
In other words, it is not sufficient to label a thought as "harmful" and then worry about it.
Instead, when the harmfulness of the harmful thought is thoroughly considered & examined, the harmful thought will end, due to truly understanding its harmful nature.

-1: <p>How can I prevent harmful thoughts and intentions from coming into my head?</p>
<p>How can I remove them if they do come into my head?</p>
<p>Even if I try to forget about them, I will still remember it. So how can I forget about them and never remember it?</p>
 19480: <p>Stop listening to them. Stop recalling them. Stop rolling them over in your mind.</p>
<p>If you stop doing all of that, they won’t draw your attention away from what is actually happening, they won’t bother you, or stress you out, and you won’t remember them because they will just evaporate as if they were never there.</p>
<p>You do all that by earnestly practicing meditation with the guidance of a qualified teacher—and preferably not a secular teacher of mindfulness because of their serious limitations.</p>
<p>Do that and you can become liberated from all the troubles of an uncontrolled mind.</p>
<p>Update:</p>
<blockquote>
<p>When you attempt to suppress emotions, thoughts, or perceptions—when you forcefully try to control them—you are chaining yourself to them. You should never try to suppress anything that arises during meditation, nor during your mindful moments during your daily life.</p>
<p>Instead, you must train your mind not to wander distractedly along with your emotions, or thoughts, or all the myriad of perceptions that arise throughout your day and practice sessions. You train your mind to remain with that which you are mindfully doing. In the case of meditation, your mind remains in the practice, whatever it is, regardless of whatever happens.</p>
<p>Of course, there are times in your normal daily life when, not having fully trained your mind, you may be distracted by some, or all, of these things and you may feel the need to try to suppress them—but remember that when you engage with them in this way you are shackling yourself to them by doing so!</p>
<p>Trying to suppress emotions, thoughts, and perceptions is at best nothing more than a quick fix that will return frequently to haunt you in your practice, and even worse, trying to do so is a sure way to become disenchanted with meditation.</p>
<p>The better way, and the one that a trained mind provides you the faculty to follow, is that you are never more than momentarily disturbed because your mind doesn’t wander, doesn’t get distracted, is totally focused as you intend to be, and is never straining—you are at ease, like an unmovable mountain. The mind thus finds great ease and calm in all that it does, and easily lets thoughts, emotions, and perceptions pass without engaging with them.</p>
<p>In between these two—a mind not yet trained, and one that is—you should strive to notice what is arising at all times. When distracting thoughts arise you should note them and then redirect your mind back to your desired center of focus. And it should be the same for emotions, as well as distracting perceptions.</p>
</blockquote>
 13694: <p>This is based mainly on my experience and in my imperfect understanding of the Dhamma. So, take this with a grain of salt.</p>
<p>I think it's useful to define &quot;<em>control</em>&quot;. If you understand 'control' as the act of making things go according to your desires, then such notion can be deceiving and illusory, if not nuanced.</p>
<p>Things arise and cease according presence of their required conditions and causes; if those don't come together in the requiered way, things will not arise.</p>
<p>Knowing the above one can should reflect on the possible way one acts on the world or in one's &quot;own&quot; mind: an <em><strong>action</strong></em> is the intervention of the present state of things of the world/mind, and which condition to come to be is <em><strong>intention</strong></em>. The result of the action will go according to your expectations if the action affects the state of things in the necessary way as to successfully bring the conditions of the desired things to come together in the necessary way it requires.</p>
<p>Action is the execution of changes in the state of things, preceded by an intention. The three main ways in which we can act is through thoughts (modifying the state of the mind), words (modifying other's state of mind) and bodily acts (modifying the physical world).</p>
<p>In order to &quot;control&quot; you mind, one should know what the desired state of things is, i.e. how you expect the mind to be after you have exerted &quot;your&quot; control and will. Once you know that, what should be done is to influence the state of things to bring the necessary conditions to the state of things desired to arise. To &quot;control&quot; the mind, you need to keep track of the state of the mind (feelings, intentions, perceptions, etc.) in every present context, and based on the context perceived, you can decide what to do with it: if the things detected are unwholesome, you can let it go or not feed it; of it's wholesome, you can keep it and develop it. The degree of success will depend on your familiarity and amount of practice with paying attention to whatever presents in the mind, and on the correct identification and effectiveness in the influence of the factors needed to lead the mind into the desired state of things.</p>
<p>Finally, the Buddha offers us a definition, categorization and explanation of what's wholesome and what's not: that is contained in the development of <a href="https://www.accesstoinsight.org/ptf/dhamma/sacca/sacca4/samma-ditthi/index.html" rel="nofollow noreferrer">Right View</a></p>
<p>Kind regards!</p>
 43: <p>The way my teachers taught me about this, it's not about &quot;controlling your mind&quot;, that's the wrong way to look at it. It is about letting go of attachments which create those disturbances. Once you clearly see your attachments and their roots (prejudices, stereotypes, traumas) then resolving them is a matter of focus and firm intent. Once attachments are out, the disturbing thoughts still by themselves.</p>
 19837: <p><strong>Pacifying the mind</strong></p>
<p>Huike said to Bodhidharma, &quot;My mind is anxious. Please pacify it.&quot;<br />
Bodhidharma replied, &quot;Bring me your mind, and I will pacify it.&quot;<br />
Huike said, &quot;Although I've sought it, I cannot find it.&quot;<br />
&quot;There,&quot; Bodhidharma replied, &quot;I have pacified your mind.&quot;</p>
<p><a href="https://en.wikipedia.org/wiki/Dazu_Huike#Pacifying_the_mind" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Dazu_Huike#Pacifying_the_mind</a></p>
<p>There's not much more to say. I'll leave you with some thoughts that may help you to realise that what you're experiencing is really not a big deal.</p>
<p>Thoughts come. If you try to control them, they will become stubborn and call more loudly for attention. You need to deal with it, but in a more relaxed way. Look at the thought without judgement. Accept its coming, its stay, and its going. You are just a spectator, not involved.</p>
<p>Still you are human and your greatest strength is love. Let the thought not be unwanted and wither away. Treasure it for its message; it came to you at this time for a reason that may not lie on the surface. It is calling you, and only you can understand. That is the treasure. With this enrichment you can bid the thought farewell.</p>
 19481: <p>Who cares if they come or go?  They aren’t you.  Do you get upset when you breath in?  Or when you put a hat on?  Why frustrate yourself with externalities?  You have no more control of your thoughts than the sky controls the number of clouds.  Does the sky worry itself on overcast days?</p>
<p>The second patriarch came to Bodhidharma’s cave.  “Master, my mind gives me no rest.  How can I pacify it?” “Show me your mind and I will pacify it for you,” the western barbarian replied.</p>
<p>There is no mind.  There is no pacification.</p>
 8157: <p>Practise what is explained in <a href="https://accesstoinsight.org/tipitaka/mn/mn.019.than.html" rel="noreferrer">MN 19</a>.</p>
<p>In other words, it is not sufficient to label a thought as &quot;harmful&quot; and then worry about it.</p>
<p>Instead, when the harmfulness of the harmful thought is thoroughly considered &amp; examined, the harmful thought will end, due to truly understanding its harmful nature.</p>
