Mou
Mou

Reputation: 16312

Run Windows service by installutil and facing permission issue c#

i developed a small windows service where sql dependency classes to monitor table changes. if table change occur then service call a web service. this service create a folder and file to save the log and also service send mail to user.

i try to copy service exe file in a folder of program files folder and issue this command installutil C:\BBA-Reman\PartIndexer\MyService.exe

getting error related message and i understood that permission is getting a issue. so i open the command prompt as run as admin and then i was my service is running fine and also could create folder & file for saving log data.

so what i did now. i add a Manifest.xml file in my project and make a association that file with my project. Manifest.xml file content here.

this area i change in manifest file for running my service with admin privilege

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

i again compile my service and just open command prompt without run as admin and issue the same command installutil C:\BBA-Reman\PartIndexer\PartIndexerService.exe getting the same permission issue related error message as before.

so please guide me how could i run my service with admin privilege by manifest file. what i am doing wrong for which i am getting error even after adding manifest file. looking for suggestion. thanks

Upvotes: 0

Views: 1102

Answers (1)

Pawel Rosinski
Pawel Rosinski

Reputation: 94

I propose to use Topshelf in your C# application, it eases the process of windows services installation.

Here you can find more details about it: http://docs.topshelf-project.com/en/latest/overview/commandline.html

Upvotes: 1

Related Questions