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
nidheesh

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
Lemur

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
fseal

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
nidheesh

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
fseal

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
richc46

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
Thread Forum
Windows Update service unable to start, Error 0x8007277a
I am having problems with my computer. I cannot seem to update anything. I am running Windows 7 Home Premium 64 bit. I first noticed that Adobe, Java, and Microsoft Security Essentials would no longer update. I have not tried to use Microsoft Update, but I am certain that would fail as well,...
Windows Updates & Activation
Unable to log onto Windows "the user profile service service failed th
I have four user accounts. none will log on. the message is the same for all "the user profile service service failed the logon" "the server endpoint cannot perform the operation" Googling the message yielded no relevant results and results full of spammy results
General Discussion
Windows Firewall Service unable to activate, SFC scan unable to work
Well I got a big problem. A couple days ago I noticed network connectivity issues. Random connection drops, overall bad connection, etc. I recently had some really bad malware and I removed it, so I suspected leftover malware from the start. I went to check Windows Update to see if I missed a...
System Security
Batch file to start a service if the service is not running
Here what I want : if servicename is running, do nothing. if servicename is not running, then start servicename, then record the date and time. based on my search online, here is what I have so far: net start | find "servicename" > nul 2>&1
General Discussion
Unable to start .jar file as a window service
Hello Everyone, This is my 1st thread, so i'm naive about the categories under which the issue i'm facing falls. I've a jar file which contains a very simple program of displaying "Hello" message in the console.I've pasted the code at the end of this thread.I want to run this jar file as a...
Software
Unable to start Service
I'm unable to start marc updater's service http://www.mediafire.com/imgbnc.php/059b1d657f51c75dfe5d77827bff64cb2e95fc88b9ec0b26c0be1ecb1011d7e42g.jpg It give this error http://www.mediafire.com/imgbnc.php/06b6ac94242b7007c7e58d8ff62278780196f181ebd4157779c6f30beccbc1702g.jpg
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 19:13.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App