简体   繁体   中英

Access Denied. installutil.exe installation after rebuilding in VS Express 2013

This is my first time in C#, and I was following this tutorial in order to test out a Directory Monitoring Service. The relevant installation steps is in Step 6:

http://www.rhyous.com/2012/11/27/c-creating-a-service-to-monitor-a-directory/

Step 6 – Install the Service
Open the Developer Command Prompt by right-clicking and choosing Run as   
Administrator.
In the command prompt, change to the bin\debug folder in your project 
directory.
Run this command to install the service:
installutil.exe DirectoryMonitoring.exe

Start the service with this command.
net start DirectoryMonitoringService

After following the tutorial, my service was able to install and run after building using the Visual Studio Development Console. I then updated my code a little and built it again.

I tried using the same steps to install or run the service via the VSD console again, but I get an Accessed Denied error when I try to do either commands.

I get the following error for the installation:

System.InvalidOperationException: Cannot open Service Control Manager on     
computer '.'. This operation might require other priviledges.
The inner exception System.ComponentModel.Win32Exception was thrown with the 
following error message: Access is denied.

I also get the following error for net start:

The service name is invalid.

What is going on? I was able to do everything perfectly the first time. Why is it not working now?

If you have the services window open, close it and then try doing the reinstall again.

Also, don't forget to uninstall the service before reinstalling it. However, in my experience, I'm pretty sure that once the service is installed just replacing the EXE with the updated service and restarting it is sufficient and I have gotten away without having to reinstall the service. YMMV.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM