Windows Service - UnauthorizedAccessException Error when Installing Service (C#)












2















So I am trying to create a service using C# in Visual Studio 2017 and I keep getting an error when I try to install it.



Right now, I don't even have anything in my service, I just want to be able to install the service. I created a new Project in Visual Studio 2017 using the Windows Service (.NET Framework) template under Visual C# > Windows Desktop. I then added the installer via Right Click > Add Installer. For serviceProcessInstaller1, I set the account to LocalSystem. And...that's it!



Now, I try to install it. I open up command prompt (run as administrator) and I do



InstallUtil ServiceTest.exe


Things start off smoothly, but then I get a message:




"An exception occured during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an
unauthorized operation."




What could be generating this message?



I've googled and tried the following things:




  • Ensure I run command prompt as administrator.

  • Assign Full Control to
    the project folder to my admin account.

  • Configure permissions to Full
    Control for admin account in the security log of regedit.

  • Log into my
    computer as an administrator (rather than regular user) and run it
    that way.


Despite these things, I keep getting the same error. What else could I be doing wrong? Would really appreciate some advice!



Note: I am trying to install this service locally on my computer.



Edit: Per request, here are the logs. I named my project "FailedService", by the way, since I can't get it to work!



InstallUtil.InstallLog



Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

An exception occurred during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.


FailedService.InstallLog



Installing assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Installing service Service1...
Creating EventLog source Service1 in log Application...
Rolling back assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Restoring event log to previous state for source Service1.









share|improve this question

























  • could you show the parts of your code where you override the oninstallation method to set the user account to localsystem? try leaving that out at first, does it work then?

    – dlatikay
    Nov 21 '18 at 15:39













  • related: stackoverflow.com/a/15502739/1132334, stackoverflow.com/a/2205777/1132334

    – dlatikay
    Nov 21 '18 at 15:49













  • I don't think I overrode the oninstallation method... To set the user account to local system, I had ProjectInstaller.cs open in Design View, I left clicked on serviceProcessInstaller1, and in the properties box beneath Misc, I set Account to "LocalSystem". Not sure if it matters, but I tried LocalService and NetworkService and received the same results. Would you still like to see my code - I left everything as default and did not make any modifications other than what I mentioned?

    – nightmare637
    Nov 21 '18 at 15:52











  • Not sure, what your service does, simple guessing ... there is a check-box for installed services, that 'Allow service to interact with desktop'. Please read this post, since setting that flag might be a security concern (it can be set programmatically).

    – nilsK
    Nov 21 '18 at 15:55











  • nilsK, I have to have the service installed in the first place to be able to check that flag.

    – nightmare637
    Nov 21 '18 at 16:11
















2















So I am trying to create a service using C# in Visual Studio 2017 and I keep getting an error when I try to install it.



Right now, I don't even have anything in my service, I just want to be able to install the service. I created a new Project in Visual Studio 2017 using the Windows Service (.NET Framework) template under Visual C# > Windows Desktop. I then added the installer via Right Click > Add Installer. For serviceProcessInstaller1, I set the account to LocalSystem. And...that's it!



Now, I try to install it. I open up command prompt (run as administrator) and I do



InstallUtil ServiceTest.exe


Things start off smoothly, but then I get a message:




"An exception occured during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an
unauthorized operation."




What could be generating this message?



I've googled and tried the following things:




  • Ensure I run command prompt as administrator.

  • Assign Full Control to
    the project folder to my admin account.

  • Configure permissions to Full
    Control for admin account in the security log of regedit.

  • Log into my
    computer as an administrator (rather than regular user) and run it
    that way.


Despite these things, I keep getting the same error. What else could I be doing wrong? Would really appreciate some advice!



Note: I am trying to install this service locally on my computer.



Edit: Per request, here are the logs. I named my project "FailedService", by the way, since I can't get it to work!



InstallUtil.InstallLog



Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

An exception occurred during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.


FailedService.InstallLog



Installing assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Installing service Service1...
Creating EventLog source Service1 in log Application...
Rolling back assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Restoring event log to previous state for source Service1.









share|improve this question

























  • could you show the parts of your code where you override the oninstallation method to set the user account to localsystem? try leaving that out at first, does it work then?

    – dlatikay
    Nov 21 '18 at 15:39













  • related: stackoverflow.com/a/15502739/1132334, stackoverflow.com/a/2205777/1132334

    – dlatikay
    Nov 21 '18 at 15:49













  • I don't think I overrode the oninstallation method... To set the user account to local system, I had ProjectInstaller.cs open in Design View, I left clicked on serviceProcessInstaller1, and in the properties box beneath Misc, I set Account to "LocalSystem". Not sure if it matters, but I tried LocalService and NetworkService and received the same results. Would you still like to see my code - I left everything as default and did not make any modifications other than what I mentioned?

    – nightmare637
    Nov 21 '18 at 15:52











  • Not sure, what your service does, simple guessing ... there is a check-box for installed services, that 'Allow service to interact with desktop'. Please read this post, since setting that flag might be a security concern (it can be set programmatically).

    – nilsK
    Nov 21 '18 at 15:55











  • nilsK, I have to have the service installed in the first place to be able to check that flag.

    – nightmare637
    Nov 21 '18 at 16:11














2












2








2








So I am trying to create a service using C# in Visual Studio 2017 and I keep getting an error when I try to install it.



Right now, I don't even have anything in my service, I just want to be able to install the service. I created a new Project in Visual Studio 2017 using the Windows Service (.NET Framework) template under Visual C# > Windows Desktop. I then added the installer via Right Click > Add Installer. For serviceProcessInstaller1, I set the account to LocalSystem. And...that's it!



Now, I try to install it. I open up command prompt (run as administrator) and I do



InstallUtil ServiceTest.exe


Things start off smoothly, but then I get a message:




"An exception occured during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an
unauthorized operation."




What could be generating this message?



I've googled and tried the following things:




  • Ensure I run command prompt as administrator.

  • Assign Full Control to
    the project folder to my admin account.

  • Configure permissions to Full
    Control for admin account in the security log of regedit.

  • Log into my
    computer as an administrator (rather than regular user) and run it
    that way.


Despite these things, I keep getting the same error. What else could I be doing wrong? Would really appreciate some advice!



Note: I am trying to install this service locally on my computer.



Edit: Per request, here are the logs. I named my project "FailedService", by the way, since I can't get it to work!



InstallUtil.InstallLog



Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

An exception occurred during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.


FailedService.InstallLog



Installing assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Installing service Service1...
Creating EventLog source Service1 in log Application...
Rolling back assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Restoring event log to previous state for source Service1.









share|improve this question
















So I am trying to create a service using C# in Visual Studio 2017 and I keep getting an error when I try to install it.



Right now, I don't even have anything in my service, I just want to be able to install the service. I created a new Project in Visual Studio 2017 using the Windows Service (.NET Framework) template under Visual C# > Windows Desktop. I then added the installer via Right Click > Add Installer. For serviceProcessInstaller1, I set the account to LocalSystem. And...that's it!



Now, I try to install it. I open up command prompt (run as administrator) and I do



InstallUtil ServiceTest.exe


Things start off smoothly, but then I get a message:




"An exception occured during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an
unauthorized operation."




What could be generating this message?



I've googled and tried the following things:




  • Ensure I run command prompt as administrator.

  • Assign Full Control to
    the project folder to my admin account.

  • Configure permissions to Full
    Control for admin account in the security log of regedit.

  • Log into my
    computer as an administrator (rather than regular user) and run it
    that way.


Despite these things, I keep getting the same error. What else could I be doing wrong? Would really appreciate some advice!



Note: I am trying to install this service locally on my computer.



Edit: Per request, here are the logs. I named my project "FailedService", by the way, since I can't get it to work!



InstallUtil.InstallLog



Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

An exception occurred during the Install phase.
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe assembly's progress.
The file is located at C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.


FailedService.InstallLog



Installing assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Installing service Service1...
Creating EventLog source Service1 in log Application...
Rolling back assembly 'C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.InstallLog
assemblypath = C:Usersfirst.m.lastsourcereposFailedServiceFailedServicebinDebugFailedService.exe
Restoring event log to previous state for source Service1.






c# windows service windows-services installutil






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 16:35







nightmare637

















asked Nov 21 '18 at 15:37









nightmare637nightmare637

729




729













  • could you show the parts of your code where you override the oninstallation method to set the user account to localsystem? try leaving that out at first, does it work then?

    – dlatikay
    Nov 21 '18 at 15:39













  • related: stackoverflow.com/a/15502739/1132334, stackoverflow.com/a/2205777/1132334

    – dlatikay
    Nov 21 '18 at 15:49













  • I don't think I overrode the oninstallation method... To set the user account to local system, I had ProjectInstaller.cs open in Design View, I left clicked on serviceProcessInstaller1, and in the properties box beneath Misc, I set Account to "LocalSystem". Not sure if it matters, but I tried LocalService and NetworkService and received the same results. Would you still like to see my code - I left everything as default and did not make any modifications other than what I mentioned?

    – nightmare637
    Nov 21 '18 at 15:52











  • Not sure, what your service does, simple guessing ... there is a check-box for installed services, that 'Allow service to interact with desktop'. Please read this post, since setting that flag might be a security concern (it can be set programmatically).

    – nilsK
    Nov 21 '18 at 15:55











  • nilsK, I have to have the service installed in the first place to be able to check that flag.

    – nightmare637
    Nov 21 '18 at 16:11



















  • could you show the parts of your code where you override the oninstallation method to set the user account to localsystem? try leaving that out at first, does it work then?

    – dlatikay
    Nov 21 '18 at 15:39













  • related: stackoverflow.com/a/15502739/1132334, stackoverflow.com/a/2205777/1132334

    – dlatikay
    Nov 21 '18 at 15:49













  • I don't think I overrode the oninstallation method... To set the user account to local system, I had ProjectInstaller.cs open in Design View, I left clicked on serviceProcessInstaller1, and in the properties box beneath Misc, I set Account to "LocalSystem". Not sure if it matters, but I tried LocalService and NetworkService and received the same results. Would you still like to see my code - I left everything as default and did not make any modifications other than what I mentioned?

    – nightmare637
    Nov 21 '18 at 15:52











  • Not sure, what your service does, simple guessing ... there is a check-box for installed services, that 'Allow service to interact with desktop'. Please read this post, since setting that flag might be a security concern (it can be set programmatically).

    – nilsK
    Nov 21 '18 at 15:55











  • nilsK, I have to have the service installed in the first place to be able to check that flag.

    – nightmare637
    Nov 21 '18 at 16:11

















could you show the parts of your code where you override the oninstallation method to set the user account to localsystem? try leaving that out at first, does it work then?

– dlatikay
Nov 21 '18 at 15:39







could you show the parts of your code where you override the oninstallation method to set the user account to localsystem? try leaving that out at first, does it work then?

– dlatikay
Nov 21 '18 at 15:39















related: stackoverflow.com/a/15502739/1132334, stackoverflow.com/a/2205777/1132334

– dlatikay
Nov 21 '18 at 15:49







related: stackoverflow.com/a/15502739/1132334, stackoverflow.com/a/2205777/1132334

– dlatikay
Nov 21 '18 at 15:49















I don't think I overrode the oninstallation method... To set the user account to local system, I had ProjectInstaller.cs open in Design View, I left clicked on serviceProcessInstaller1, and in the properties box beneath Misc, I set Account to "LocalSystem". Not sure if it matters, but I tried LocalService and NetworkService and received the same results. Would you still like to see my code - I left everything as default and did not make any modifications other than what I mentioned?

– nightmare637
Nov 21 '18 at 15:52





I don't think I overrode the oninstallation method... To set the user account to local system, I had ProjectInstaller.cs open in Design View, I left clicked on serviceProcessInstaller1, and in the properties box beneath Misc, I set Account to "LocalSystem". Not sure if it matters, but I tried LocalService and NetworkService and received the same results. Would you still like to see my code - I left everything as default and did not make any modifications other than what I mentioned?

– nightmare637
Nov 21 '18 at 15:52













Not sure, what your service does, simple guessing ... there is a check-box for installed services, that 'Allow service to interact with desktop'. Please read this post, since setting that flag might be a security concern (it can be set programmatically).

– nilsK
Nov 21 '18 at 15:55





Not sure, what your service does, simple guessing ... there is a check-box for installed services, that 'Allow service to interact with desktop'. Please read this post, since setting that flag might be a security concern (it can be set programmatically).

– nilsK
Nov 21 '18 at 15:55













nilsK, I have to have the service installed in the first place to be able to check that flag.

– nightmare637
Nov 21 '18 at 16:11





nilsK, I have to have the service installed in the first place to be able to check that flag.

– nightmare637
Nov 21 '18 at 16:11












2 Answers
2






active

oldest

votes


















0














Enter the full path to installUtil & your service binary in an elevated prompt, that could do.






share|improve this answer


























  • how/why is that different to "I run command prompt as administrator"

    – dlatikay
    Nov 21 '18 at 15:44











  • As dlatikay said, I am already running the prompt as administrator. Also, I was running installUtil from the full path to begin with. I was not running the service binary in the full path since I was already working from that directory to begin with. However, I did try running both from the full path and it still did not work.

    – nightmare637
    Nov 21 '18 at 15:48











  • The point is not in "as administrator" but in "full path". it's a well known bug that i aslo encountered myself. but anyway, it did not work

    – Kianii
    Nov 21 '18 at 15:56











  • No, but thank you so much for your suggestion!

    – nightmare637
    Nov 21 '18 at 16:08



















0














I was FINALLY able to resolve this issue. I was able to get to the bottom of it by using SysInternal's Process Monitor. I opened up the program and had it take logs for InstallUtil.exe. From there, I began to search for any logs that said "Access Denied". As I sorted through them, I noticed something interesting: it was trying to create a registry key, but it kept failing!



So I went into the registry and created a key named "ServiceTest". After that, I ran the InstallUtil command again, and it worked!



If anyone else is having trouble, the solution is to create a key named after your process name in the following location:



HKLMSystemCurrentControlSetServicesEventLogApplication






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415545%2fwindows-service-unauthorizedaccessexception-error-when-installing-service-c%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Enter the full path to installUtil & your service binary in an elevated prompt, that could do.






    share|improve this answer


























    • how/why is that different to "I run command prompt as administrator"

      – dlatikay
      Nov 21 '18 at 15:44











    • As dlatikay said, I am already running the prompt as administrator. Also, I was running installUtil from the full path to begin with. I was not running the service binary in the full path since I was already working from that directory to begin with. However, I did try running both from the full path and it still did not work.

      – nightmare637
      Nov 21 '18 at 15:48











    • The point is not in "as administrator" but in "full path". it's a well known bug that i aslo encountered myself. but anyway, it did not work

      – Kianii
      Nov 21 '18 at 15:56











    • No, but thank you so much for your suggestion!

      – nightmare637
      Nov 21 '18 at 16:08
















    0














    Enter the full path to installUtil & your service binary in an elevated prompt, that could do.






    share|improve this answer


























    • how/why is that different to "I run command prompt as administrator"

      – dlatikay
      Nov 21 '18 at 15:44











    • As dlatikay said, I am already running the prompt as administrator. Also, I was running installUtil from the full path to begin with. I was not running the service binary in the full path since I was already working from that directory to begin with. However, I did try running both from the full path and it still did not work.

      – nightmare637
      Nov 21 '18 at 15:48











    • The point is not in "as administrator" but in "full path". it's a well known bug that i aslo encountered myself. but anyway, it did not work

      – Kianii
      Nov 21 '18 at 15:56











    • No, but thank you so much for your suggestion!

      – nightmare637
      Nov 21 '18 at 16:08














    0












    0








    0







    Enter the full path to installUtil & your service binary in an elevated prompt, that could do.






    share|improve this answer















    Enter the full path to installUtil & your service binary in an elevated prompt, that could do.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 21 '18 at 16:00

























    answered Nov 21 '18 at 15:41









    KianiiKianii

    1368




    1368













    • how/why is that different to "I run command prompt as administrator"

      – dlatikay
      Nov 21 '18 at 15:44











    • As dlatikay said, I am already running the prompt as administrator. Also, I was running installUtil from the full path to begin with. I was not running the service binary in the full path since I was already working from that directory to begin with. However, I did try running both from the full path and it still did not work.

      – nightmare637
      Nov 21 '18 at 15:48











    • The point is not in "as administrator" but in "full path". it's a well known bug that i aslo encountered myself. but anyway, it did not work

      – Kianii
      Nov 21 '18 at 15:56











    • No, but thank you so much for your suggestion!

      – nightmare637
      Nov 21 '18 at 16:08



















    • how/why is that different to "I run command prompt as administrator"

      – dlatikay
      Nov 21 '18 at 15:44











    • As dlatikay said, I am already running the prompt as administrator. Also, I was running installUtil from the full path to begin with. I was not running the service binary in the full path since I was already working from that directory to begin with. However, I did try running both from the full path and it still did not work.

      – nightmare637
      Nov 21 '18 at 15:48











    • The point is not in "as administrator" but in "full path". it's a well known bug that i aslo encountered myself. but anyway, it did not work

      – Kianii
      Nov 21 '18 at 15:56











    • No, but thank you so much for your suggestion!

      – nightmare637
      Nov 21 '18 at 16:08

















    how/why is that different to "I run command prompt as administrator"

    – dlatikay
    Nov 21 '18 at 15:44





    how/why is that different to "I run command prompt as administrator"

    – dlatikay
    Nov 21 '18 at 15:44













    As dlatikay said, I am already running the prompt as administrator. Also, I was running installUtil from the full path to begin with. I was not running the service binary in the full path since I was already working from that directory to begin with. However, I did try running both from the full path and it still did not work.

    – nightmare637
    Nov 21 '18 at 15:48





    As dlatikay said, I am already running the prompt as administrator. Also, I was running installUtil from the full path to begin with. I was not running the service binary in the full path since I was already working from that directory to begin with. However, I did try running both from the full path and it still did not work.

    – nightmare637
    Nov 21 '18 at 15:48













    The point is not in "as administrator" but in "full path". it's a well known bug that i aslo encountered myself. but anyway, it did not work

    – Kianii
    Nov 21 '18 at 15:56





    The point is not in "as administrator" but in "full path". it's a well known bug that i aslo encountered myself. but anyway, it did not work

    – Kianii
    Nov 21 '18 at 15:56













    No, but thank you so much for your suggestion!

    – nightmare637
    Nov 21 '18 at 16:08





    No, but thank you so much for your suggestion!

    – nightmare637
    Nov 21 '18 at 16:08













    0














    I was FINALLY able to resolve this issue. I was able to get to the bottom of it by using SysInternal's Process Monitor. I opened up the program and had it take logs for InstallUtil.exe. From there, I began to search for any logs that said "Access Denied". As I sorted through them, I noticed something interesting: it was trying to create a registry key, but it kept failing!



    So I went into the registry and created a key named "ServiceTest". After that, I ran the InstallUtil command again, and it worked!



    If anyone else is having trouble, the solution is to create a key named after your process name in the following location:



    HKLMSystemCurrentControlSetServicesEventLogApplication






    share|improve this answer




























      0














      I was FINALLY able to resolve this issue. I was able to get to the bottom of it by using SysInternal's Process Monitor. I opened up the program and had it take logs for InstallUtil.exe. From there, I began to search for any logs that said "Access Denied". As I sorted through them, I noticed something interesting: it was trying to create a registry key, but it kept failing!



      So I went into the registry and created a key named "ServiceTest". After that, I ran the InstallUtil command again, and it worked!



      If anyone else is having trouble, the solution is to create a key named after your process name in the following location:



      HKLMSystemCurrentControlSetServicesEventLogApplication






      share|improve this answer


























        0












        0








        0







        I was FINALLY able to resolve this issue. I was able to get to the bottom of it by using SysInternal's Process Monitor. I opened up the program and had it take logs for InstallUtil.exe. From there, I began to search for any logs that said "Access Denied". As I sorted through them, I noticed something interesting: it was trying to create a registry key, but it kept failing!



        So I went into the registry and created a key named "ServiceTest". After that, I ran the InstallUtil command again, and it worked!



        If anyone else is having trouble, the solution is to create a key named after your process name in the following location:



        HKLMSystemCurrentControlSetServicesEventLogApplication






        share|improve this answer













        I was FINALLY able to resolve this issue. I was able to get to the bottom of it by using SysInternal's Process Monitor. I opened up the program and had it take logs for InstallUtil.exe. From there, I began to search for any logs that said "Access Denied". As I sorted through them, I noticed something interesting: it was trying to create a registry key, but it kept failing!



        So I went into the registry and created a key named "ServiceTest". After that, I ran the InstallUtil command again, and it worked!



        If anyone else is having trouble, the solution is to create a key named after your process name in the following location:



        HKLMSystemCurrentControlSetServicesEventLogApplication







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 8 at 15:14









        nightmare637nightmare637

        729




        729






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415545%2fwindows-service-unauthorizedaccessexception-error-when-installing-service-c%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules