NetAddUser RRS feed

  • Question


    Can I add NetuserAdd and add that user in administrative group if I am running my application as standard user. My application works for both Win XP and Vista.
    Friday, July 18, 2008 6:55 AM

All replies

  • No, you need to be elevated to modify the Administrators group (for fairly obvious reasons).


    Friday, July 18, 2008 9:03 AM
  • Yes, I have a genuine reason because I want to use OpenScManager and then open service, start/stop service, which I can not run as standard user.

    So I was thinking that this is the solution to add user and then add it in administrative group. I already have used manifest file with my exe file, however OpenScManager is still saying AccessDenied.


    Friday, July 18, 2008 3:03 PM
  • However, I am confused what are the steps to take.


    Friday, July 18, 2008 3:04 PM
  • Even an account in the Administrators group can't start/stop services without going through a UAC elevation by default.


    If you're writing a service that needs to be restartable by standard users, you'll need to change the ACLs on the service. To avoid DOS attacks you'd usually change the service ACL to allow standard users to start the service and then initiate the shutdown from within the service itself.

    Friday, July 18, 2008 3:09 PM
  • I changed ACL on my application services, however they were already running well without changing ACL independently. 

    I can not change on service itself, as it is only allowed by trusted connection.


    If I run this from program, it fails, that is why I wanted to change elevation for standard user. 

    hManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );

    This command gets failed if I am running it as standard user.


    Thank you!


    Friday, July 18, 2008 4:25 PM