Unable start a service when UAC is Default (ON)

nidheesh

New member
Local time
4:43 AM
Messages
5
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 My Computer

At a glance

Windows 7(64 Bit)
Computer Manufacturer/Model Number
Dell
OS
Windows 7(64 Bit)
My understanding is the UAC defines user admin roles. Therefore, admin rights would be required to start a service.
 

My Computer My Computer

At a glance

Systems 1 and 2: Windows 7 Enterprise x64, Wi...System 1: i7 [email protected], System 2: AMD FX-41...System 1: 8GB System 2: 8GBSystem 1: ATI FirePro V4800 System 2: Radeon ...
Computer Manufacturer/Model Number
Dell and Custom
OS
Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
CPU
System 1: i7 [email protected], System 2: AMD FX-4100 Zambezi 3.6G
Motherboard
System 1:Dell 06NWYK System 2: ASUS M5A97 AM3+
Memory
System 1: 8GB System 2: 8GB
Graphics Card(s)
System 1: ATI FirePro V4800 System 2: Radeon HD 6850
Sound Card
System 1: onboard System 2: onboard
Monitor(s) Displays
System1: Viewsonic HDMI 24"
Screen Resolution
System 1: 1920x1080 System 2: 1920x1080
Hard Drives
System 1: Mirrored .5B drives System 2: Seagate Barracuda ST1000DM003 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s
Case
System 1: Dell System 2: Cooler Master
Internet Speed
10 MBPS
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 My Computer

At a glance

Windows 7 x64 Ultimatei7 96012 Gig Corsair DominatorNvidia 480
Computer Manufacturer/Model Number
Scratch built
OS
Windows 7 x64 Ultimate
CPU
i7 960
Motherboard
Asus P6X58D
Memory
12 Gig Corsair Dominator
Graphics Card(s)
Nvidia 480
Sound Card
Maudio Delta 44 + breakout box
Monitor(s) Displays
Dell UltraSharp U2410 24in and Samsung 21 dual monitors
Screen Resolution
1920x1200 and 1280x1024
Hard Drives
Primary: Intel X-25M G2 160G SSD
Secondary: Segate baracuda 1.0 TB
HDs in AHCI mode.
PSU
Corasair TX850
Case
Cooler Master HAF
Cooling
Corsair H50
Keyboard
Logitech G15 + N52 game pad
Mouse
Logitech MX518
Internet Speed
15kbs down 4.5kbps up
Other Info
WEI 7.6
CPU & RAM 7.6
Graphics 7.9
Hard disk 7.7
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 My Computer

At a glance

Windows 7(64 Bit)
Computer Manufacturer/Model Number
Dell
OS
Windows 7(64 Bit)
Right, when it returns 0 you need to "GetLastError()" to find out why...
 

My Computer My Computer

At a glance

Windows 7 x64 Ultimatei7 96012 Gig Corsair DominatorNvidia 480
Computer Manufacturer/Model Number
Scratch built
OS
Windows 7 x64 Ultimate
CPU
i7 960
Motherboard
Asus P6X58D
Memory
12 Gig Corsair Dominator
Graphics Card(s)
Nvidia 480
Sound Card
Maudio Delta 44 + breakout box
Monitor(s) Displays
Dell UltraSharp U2410 24in and Samsung 21 dual monitors
Screen Resolution
1920x1200 and 1280x1024
Hard Drives
Primary: Intel X-25M G2 160G SSD
Secondary: Segate baracuda 1.0 TB
HDs in AHCI mode.
PSU
Corasair TX850
Case
Cooler Master HAF
Cooling
Corsair H50
Keyboard
Logitech G15 + N52 game pad
Mouse
Logitech MX518
Internet Speed
15kbs down 4.5kbps up
Other Info
WEI 7.6
CPU & RAM 7.6
Graphics 7.9
Hard disk 7.7

My Computer My Computer

At a glance

Windows 10, Home Clean InstallIntel Core2 processsor Q8200(2.33Ghz 1333FSB)...6 gbATI Radeon 256MB HD3650
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell XPS 420
OS
Windows 10, Home Clean Install
CPU
Intel Core2 processsor Q8200(2.33Ghz 1333FSB) Quad Core Tech
Motherboard
Dell
Memory
6 gb
Graphics Card(s)
ATI Radeon 256MB HD3650
Sound Card
Intergrated 7.1 Channel Audio
Monitor(s) Displays
Dell SP2009W 20"
Hard Drives
640 GB Serial ATA Hard drive
Cooling
Fan
Keyboard
Dell USB Keyboard
Mouse
Dell Premium Optical USB
Internet Speed
DSL 2.85
Back
Top