Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am installing the windows service via Bat file. I even ran the bat file as administrator.The required dot net framework is also there in the machine. The OS is windows 7 64 bit. The below is developed in 3.5 framework

But on installation I am getting the below error
C#
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security


Below is the content in bat file

C#
@echo off
set SERVICE_HOME="D:\New folder (5)"
set SERVICE_EXE=PDF_Data_Tool.exe
REM the following directory is for .NET 1.1, your mileage may vary
set INSTALL_UTIL_HOME=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\

set PATH=%PATH%;%INSTALL_UTIL_HOME%

cd %SERVICE_HOME%

echo Installing Service...
installutil   %SERVICE_EXE% 

echo Done.
PAUSE


What I have tried:

Tried installing and uninstalling of windows service via the bat file as administrator/ and not as administrator

@echo off
set SERVICE_HOME="D:\New folder (5)"
set SERVICE_EXE=PDF_Data_Tool.exe
REM the following directory is for .NET 1.1, your mileage may vary
set INSTALL_UTIL_HOME=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\

set PATH=%PATH%;%INSTALL_UTIL_HOME%

cd %SERVICE_HOME%

echo Installing Service...
installutil %SERVICE_EXE%

echo Done.
PAUSE
Posted
Updated 20-Apr-16 2:35am
Comments
Richard MacCutchan 20-Apr-16 8:13am    
What happens when you run these commands direct from a command prompt? Also where is PDF_Data_Tool.exe?
Richard Deeming 20-Apr-16 8:14am    
Are you running the batch file from an elevated command prompt?
ranio 20-Apr-16 8:27am    
The files during release are set alongside with the PDF_Data_Tool exe. The bat file for installation/Uninstallation path is set where the release files in the folder.
set SERVICE_HOME="D:\New folder (5)"
set SERVICE_EXE=PDF_Data_Tool.exe
REM the following directory is for .NET 1.1, your mileage may vary
set INSTALL_UTIL_HOME=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\

set PATH=%PATH%;%INSTALL_UTIL_HOME%
Dave Kreskowiak 20-Apr-16 8:29am    
Whoever is running the bat file has to be an admin to install a service.

1 solution

it is
installutil -i %SERVICE_EXE% to install a service and
installutil -u %SERVICE_EXE% to UNinstall a service
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900