Install C # Windows Service on Windows 7

I have a batch file that I used to install my C # Windows Services for a while, there was never a problem before Windows 7. I tried to run the batch file as administrator. I tried to run the command line using admin privs, go to the Windows EXE service and run InstallUtil there. Still not working.

After reading some other suggestions, I tried moving my files from the / bin folder and running them from another location, but that also did not work.

The batch file is as follows:

@ECHO OFF REM The following directory is for .NET 2.0 set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727 set PATH=%PATH%;%DOTNETFX2% echo Installing IEPPAMS Win Service... echo --------------------------------------------------- InstallUtil /i IEPPAMS_WinService1.exe echo --------------------------------------------------- echo Done. 

and I have an installation log file to which I send information. If I just double-click the .bat file, I get

Starting a transactional installation.

Beginning of the installation phase installation. See the contents of the log file for C: \ Users \ Justin \ Desktop \ Service Test \ IEPPAMS_WinService1.exe build progress. The file is located in C: \ Users \ Justin \ Desktop \ Service Test \ IEPPAMS_WinService1.InstallLog.

An exception occurred during the installation phase. System.InvalidOperationException: Cannot open Computer Service Control Manager. This operation may require other privileges. An internal exception System.ComponentModel.Win32Exception was thrown with the following error message: Access denied.

The rollback of the installation phase begins. See the contents of the log file for C: \ Users \ Justin \ Desktop \ Service Test \ IEPPAMS_WinService1.exe build progress. The file is located in C: \ Users \ Justin \ Desktop \ Service Test \ IEPPAMS_WinService1.InstallLog.

Rollback completed successfully.

Completed transaction completed.

When I run the .bat file as administrator, nothing is written to the log file and the service is still not installed.

Any thoughts? Is there a new way to install services in Windows 7?

+7
c # windows-7 windows-services
source share
3 answers

So, I was able to fix this problem by entering the entire path to InstallUtil on the command line, and it worked. Therefore, after going to the folder with my EXE, I typed the following:

C: \ Windows \ Microsoft.NET \ Framework \ v4.0.21006 \ installutil.exe IEPPAMS_WinService1.exe

Not sure why I should do this in Windows 7 now, when I never had to in XP, but fine. Thanks for all the suggestions!

+8
source share

Right-click on the batch file and run it as Administrator.

Most likely, you will encounter a battle with the new security model (User Account Control) from Windows Vista and Windows 7. Even if you are working as an account with administrator rights, you still need to raise to do some (most) of the administrative activities. (Yes, you can disable this feature, but do not)

Edit ... The correct InstallUtil YourApp.exe command line InstallUtil YourApp.exe . /i does not look like the vaild switch for InstallUtil .

+11
source share

When I run the .bat file as administrator, nothing is written to the log file and the service is still not installed.

First, you must be an administrator.

Secondly, when you "Run as administrator", it actually changes the directory to c: \ windows \ system32 as the source directory (I don’t know why), which probably explains why starting as administrator does not call any log file . Manually change the path to the IEPPAMS_WinService1.exe file in that the beginning of your script.

+3
source share

All Articles