How do I edit modules from code?

I have a custom app that creates a system user for me on installation. I want to also edit that user’s modules to only allow a few. Can I please be pointed in the right direction?

Anyone?