I want to create a windows service that would start before user can login. I want it to start before login so I can remove a user (windows user) from group (HomeUser to be precise), so I dont have to re-login.
So I want to:
- Create a service that starts before user can login
- Remove a user from group.
Any idea how this can be accomplished in C#?
Edit
For part-2 of question; Here the link on how you can do this: http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.groupprincipal.members.aspx
How to do it:
Use the
Windows Service(not WCF service!) project type in Visual Studio.Put your implementation in the
OnStart´ method. Add a projectInstaller and configure it to install the service in theStarted´ mode.compile your project, run `installutil.exe -i´ on your projects.exe
That should install your service, and on next boot have it start.
Why to do it?:
Tbh, it sounds to me like something that is done once, not every boot ´removing a user from a group´. Unless someone else puts the user back in the group, its going to stay the way you set it last.. So, doing it every cold-boot sounds redundant.
Also remember, modifying security settings is a pretty high privilege. Not many accounts are allowed to do this. Make sure your service is installed with an identity which has permission to these levels.