I want to give a different perspective than the US one, for completeness sake.
For the record, I'm based in Germany. Here the university, even Bachelors, is quite an academic study (although this is changing, but nobody really has a clear vision forward) and depending on the field a Bachelors, and more so a Masters, doesn't give any benefit when you're not going to be an academic (be it in your later job or because you enjoy the general education).
Frequently, in Computer Science, we have the case of people dreaming to be programmers or system administrators, something the Bachelor doesn't really prepare you for. Unfortunately, most do not make this realization after >4 years of frustration about the theoretical focus. However, there are institutions that provide you with the skills to become a programmer. Due to a rather wrong and twisted picture of what CS is, people don't even consider these.
If (not professor, but I regularly teach my own course at uni) I notice things like these, I try to clear up misunderstandings about it: "You won't learn these skills here, though" or "Yes, you need to learn higher maths in CS to go into academic computer sciences". I usually advice them to take 1,2 semesters to test waters and then decide while also showing them alternatives and emphasizing that going into a non-academic field is not less good, but equally valued.
So rather than blatantly saying "drop out" I do:
- clear any misunderstandings about wrong expectations
- focus on expectations and plans they have voiced
- let them take a bit of time, maybe they change their viewpoint
- make clear that dropping out isn't bad, you just pursue a different path. It's more comparable to switching majors.
I've also seen students who, after that talk, took those courses that they've failed again. But now with higher interest, as they recognized their value for CS while before they evaluated them w.r.t. programming. They then noticed that the course they dismissed as boring and useless is actually fun and adjusted their goal to become an academic.
But many don't want to become academics. We currently have a public chat for the whole department including everyone who's here, ie. students, secretaries, TAs, PhDs, profs, etc. with quite enlightening conversations. One was basically students saying that they wish university had been more clear about its goals upfront, as almost noone knows what CS is when starting the studies.
Note: As I view it (and have experienced it to be) profs and students are in this together, ideally knowing each other quite well. The profs aren't just there to hold lectures and then vanish into their offices. In this environment it's rather frequent that the prof is not only seen as a lecturer and examiner but advisor and mentor.