Unable start a service when UAC is Default (ON)


  1. Posts : 5
    Windows 7(64 Bit)
       #1

    Unable start a service when UAC is Default (ON)


    Hi Friends,

    I created a new Windows Service using C#. And Created a windows application to CREATE SERVICE, START SERVICE, STOP SERVICE and DELETE the SERVICE. This application is working fine when the UAC is turned OFF. When the UAC is
    turned ON then none of the above operations are working.

    1. Can i create a Service without Admin Rights, for creating am using the following

    IntPtr sc_handle = OpenSCManager(null, null, SC_MANAGER_CREATE_SERVICE);
    if (sc_handle.ToInt32() != 0)
    {
    IntPtr sv_handle = CreateService(sc_handle, svcName, svcDispName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, svcPath, null, 0, null, null, null);
    CloseServiceHandle(sc_handle);
    }

    [DllImport("Advapi32.dll")]
    public static extern IntPtr CreateService(IntPtr SC_HANDLE, string lpSvcName, string lpDisplayName, int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl, string lpPathName, string lpLoadOrderGroup, int lpdwTagId, string lpDependencies, string lpServiceStartName, string lpPassword);

    2. Can i start the Service without admin Rights

    Can any one please tell me how to solve this issue.

    Regards,
    Nidheesh
      My Computer


  2. Posts : 3,139
    Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
       #2

    My understanding is the UAC defines user admin roles. Therefore, admin rights would be required to start a service.
      My Computer


  3. Posts : 2,528
    Windows 7 x64 Ultimate
       #3

    I would carefully look over the help item for that call. By default it tries to install it to run under the local system account. You may want to supply a user account to run that service under inthe CreateService call instead. Also if you do want to install it for the system account or admin account, you probably have to run the program that does the calls above under an admin account to get it to work.

    Does the function call fail entirely with UAC on (Handle would be NULL)? What is the error code?
      My Computer


  4. Posts : 5
    Windows 7(64 Bit)
    Thread Starter
       #4

    fseal said:
    I would carefully look over the help item for that call. By default it tries to install it to run under the local system account. You may want to supply a user account to run that service under inthe CreateService call instead. Also if you do want to install it for the system account or admin account, you probably have to run the program that does the calls above under an admin account to get it to work.

    Does the function call fail entirely with UAC on (Handle would be NULL)? What is the error code?
    Hi,

    am getting the value for handle as 0 (sc_handle.ToInt32() != 0) .

    Regards,
    Nidheesh
      My Computer


  5. Posts : 2,528
    Windows 7 x64 Ultimate
       #5

    Right, when it returns 0 you need to "GetLastError()" to find out why...
      My Computer


  6. Posts : 17,796
    Windows 10, Home Clean Install
       #6

    Welcome
    I do have a method that works, but must be upfront about it, should be used only in emergencies. That being said it is your computer and I think you are entitiled to the information. It will work with this Administrator.
    Built-in Administrator Account - Enable or Disable[2]=User Accounts
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:01.
Find Us