How can we give permissions or revoke permissions on applications(i.e installed softwares) for a user via c#.net.
i have get the all uers list on the computer and also installed programs list but how can i change a user permissions in a way that he may not able to use some specific application like photoshop, corel draw.

Detailed Description of Problem
I have three users 'A' , 'B' and 'C' on my Computer (Standalone) . I want that Only User 'A' can use Photoshop and User 'B' can only use coreldraw. So how we can give permissions to User 'A' and 'B'. I want to do this programmaticaly through C#.NET.

please help me to solve this problem.

Thanks

Not sure how you would do that by registered application, but here is a good link/example code showing how to add/revoke privileges to particular directory for user. You could change it also to use the File class objects instead of the Directory objects if you desire. I know it's probably not exactly what you are looking for, but maybe a workaround if needed:

Security Access Control

I found this code, but havn't tried it. It shows how to revoke registry privilege for software application, and I think it might be more of what you are looking for.

public static void RevokeRegKeyRights(RegistryKey regKey,
                                      NTAccount user,
                                      RegistryRights rightsFlags,
                                      InheritanceFlags inherFlags,
                                      PropagationFlags propFlags,
                                      AccessControlType actFlags)
{
    RegistrySecurity regSecurity = regKey.GetAccessControl();

    RegistryAccessRule rule = new RegistryAccessRule(user, rightsFlags, inherFlags,
                                                     propFlags, actFlags);
    regSecurity.RemoveAccessRuleSpecific(rule);

    regKey.SetAccessControl(regSecurity);
}

I believe that if you call the above with the RegistryRights.ExecuteKey option, it should prevent that user from launching the application:

NTAccount user = new NTAccount(@"WRKSTN\ST");

            using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(
                                    @"SOFTWARE\MyCompany\MyApp"))
            {
                RevokeRegKeyRights(regKey, user, RegistryRights.ExecuteKey,
                               InheritanceFlags.None, PropagationFlags.None,
                               AccessControlType.Allow);
             }

Sorry you need to apply permission on your developed application or another applications
In case of another applications, you may the one who has the administrative permission and when install log on the i.e. 'A' account and right click on the exe and run it as administrator enter your username and password and in installation progress say just for this user. (Just if the application supports that)
You need to disable some user permissions....

You need to block a pogram execution instead of setting/resetting permission.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.