elisa
elisa

Reputation: 743

c# error on windows service

I have the following error:

 OpenSCManager Failed 5: Access is denied.  

Can someone help me? Is there another way besides using installutil to install the windows service ?

P.S : I am using Visual studio 2008. I did look for installutil in C:\VisualStudio... but i can't find it either.

I found the InstallUtil.exe executable. I run the application and now i have the error: c:...\InstallUtil,installLog is denied. WHY?

Upvotes: 0

Views: 1065

Answers (1)

seva titov
seva titov

Reputation: 11920

There are two questions here:

  1. For the access denied problem. Chances are you are don't have permissions. Run the command with administrative privilegies. This means that you have to be a member of administrators group and your process has to be elevated, i.e. you have to right-click -> Run As Administrator to lauch the process.

  2. There are many ways to install service. Since you already know InstallUtil, I don't have to mention it.

    • There is Win32 API called CreateService.
    • There is command line utility sc.exe -- it comes with OS by default
    • If you are so inclined, you can hack registry -- it is not that difficult to reverse engineer records under HKLM\System\CurrentControlSet\Service\

I personally prefer sc.exe. It installs managed services just fine.

Upvotes: 1

Related Questions