Leaving aside that dementia is not a mental illness, I'm unaware of any caused by viruses that aren't a side effect.
For example Alzheimers can be caused indirectly by viruses, but its cause isn't a virus, it's likely neuroinflammation, which can be caused by all kinds of things including bacteria and certain types of plaque.
Worse, the latter is generally because the brain's own immune system is causing the inflammation fighting said virus when it is a virus, and so a vaccine would cause more problems rather than help.
Using vaccines here is just not a practical course of action and betrays a fundamental misunderstanding of what dementia is. And mental illnesses? They're even less likely to have clear causes outside of genetics and exposure to various environmental factors not generally considered biological.