Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Unable start a service when UAC is Default (ON)


14 Feb 2012   #1

Windows 7(64 Bit)
 
 
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 System SpecsSystem Spec
.

14 Feb 2012   #2

Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
 
 

My understanding is the UAC defines user admin roles. Therefore, admin rights would be required to start a service.
My System SpecsSystem Spec
14 Feb 2012   #3

Windows 7 x64 Ultimate
 
 

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 System SpecsSystem Spec
.


14 Feb 2012   #4

Windows 7(64 Bit)
 
 

Quote   Quote: Originally Posted by fseal View Post
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 System SpecsSystem Spec
15 Feb 2012   #5

Windows 7 x64 Ultimate
 
 

Right, when it returns 0 you need to "GetLastError()" to find out why...
My System SpecsSystem Spec
15 Feb 2012   #6

Microsoft Community Contributor Award Recipient

Windows 7 Home Premium SP1, clean install, upgrade disc
 
 

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 System SpecsSystem Spec
Reply

 Unable start a service when UAC is Default (ON)




Thread Tools



Similar help and support threads for2: Unable start a service when UAC is Default (ON)
Thread Forum
"browser" Service Missing: Worksation service does not start ! General Discussion
Solved Windows Firewall Service unable to activate, SFC scan unable to work System Security
Batch file to start a service if the service is not running General Discussion
Unable to start .jar file as a window service Software
Default Programs - Change Default Icon in Start Menu Tutorials
Unable to Install Service Pack 1 Windows Updates & Activation
Unable to start Service Performance & Maintenance

Our Sites

Site Links

About Us

Find 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 02:02 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33