Windows Service not showing up in Services - c#

I created a Windows Service and a setup project.
When I installed the service using the setup installer it is properly installed on the system.
But I didn't see my service in the Services window. I gave all the right permissions, I tried to delete the setup and recreated the new setup still it didn't work.
I tried manually installing using Install Util.exe using the following command
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe C:\myproject\project1\bin\project1.exe
Still it didn't install properly... My system is Windows7 64 bit and VS2010
Is this because of 64 bit system?

You need to add an installer class to your project. Once you have the installer class added you need to add a serviceInstaller and a serviceProcessInstaller to the installer class. You then use these to give your service a display name, install name, etc. I'm surprised the installutil.exe worked without this stuff already setup.

Related

Windows service not seen in services even after successful installation

There is one windows service which is installed on one of our servers and working fine.
I tried to replicate the same on the other server, so I took the exe setup from one server to another and tried to install the windows service using installUtil.exe
It is giving me
The Commit phase was completed successfully. The transacted install has been completed.
but the service cannot be found in the services list and it is also giving me this message at the time of installation.
No public installers with the RunInstallerAttribute.Yes, the attribute could be found in the xyz.exe assembly.
Remove InstallState file because there are no installers.
and I am not sure why this is happening? I tried googling but most of them have given the solution to add installer to the project.
But if the installer is not added how the service is running on the first server
is there another way to install the service?
Could it be related to the Windows OS version?

How to add version info to Windows Service installed via Sc.exe tool?

When you install Windows Service via the wizard (using .msi file), Windows will add a record in Add or remove programs with a version number, that you can set in properties of the Wizard project.
You can also install Windows Service, using Sc.exe tool.
My question is, how to install windows service via Sc.exe tool and still have a record in Add or remove programs with a version. So I know what version of Windows Service is running. Ideal scenario would be to include the version in the code. So that Sc.exe will call MyService.exe without any parameters.
Thanks for help,

create MSI for windows service in visual studio 2012

I have created a windows service in visual studio 2012. I can install the service using installutil, but I need to distribute the service to a client.
How can I build a MSI? There are wwalk throughs in vs2008, but they don't seem to apply to 2012, as 2012 has install shield limited edition and I cannot find Custom Actions anywhere..
Do you have to distribute an MSI?
If all you want is to install the service then the application itself should do it. Use a ServiceInstaller. Add a main argumnet so when you run app.exe /install it isntalls the service (and perhaps /uninstall removes it).
The following topic explains the details: How to: Add Installers to Your Service Application. The ServiceInstaller has code example.
You should use an MSI if you have more complex requirements, if you want your app to appear in the Control Panel/Add-Remove programs, if you want to add 'Repair' installs, if your installation needs to provide options (CLI or UX).

Install a service created with VS2010

I've to create a service in Visual Studio for one customer.
The customer IT service indicate me that they don't want any installer, only one exe that can be installed with instsrv.exe.
So I created a Service project on VS2010, compilated it(in 64 bits, it's an application that has to be ran in 64bits).
First problem: I didn't found any instsrv.exe, so I used InstallUtil.exe, the 64 bits version :
C:\Windows\Microsoft.Net\Framework64\v4.0.xxxx\InstallUtil.exe "PathToMyGeneratedExe"
It says me that "The commit phase completed successfully." and "The transacted install has completed.".
So I assume that the install completed successfully.
But if I go in the service console, I can't find the created service.
So what am I missing?
InstallUtil is intended for usage with a service installer (which is really easy to make, but a bit buried) I imagine your client wasnt after a gui installer but I think it may be worth your while putting in the base serviceinstaller.
Normally InstallUtil will also prompt for a user to run the service under as well. if you havent got this you probably arent installed
Take a read of http://arcanecode.com/2007/05/23/windows-services-in-c-adding-the-installer-part-3/ for details of how to do this
(TLDR right click on your service design surface and add installer)

Installing a Windows Service -Setup.exe fails

There is a weird issue I am facing. I created my first windows service looking through various blogs and tutorials.
Then created setup for that adding installer etc. It works fine while installing , un-installing via Visual Studio but it fails when i deploy it .
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of C:\Users\bhuvint\Documents\Visual Studio 2010\Projects\CPNS Library\ServicePackage\CommonPushNotificationWindowsService.application resulted in exception. Following failure messages were detected:
+ You cannot start application CommonPushNotificationWindowsService from this location because it is already installed from a different location.
+ You cannot start application CommonPushNotificationWindowsService from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application it is already installed from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application. You can start it from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application or you can uninstall it and reinstall it from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application.
I have already un-installed the service and trying to install it from the deployed service in the same pc to test. But it fails with above error.
I feel i have deployed the windows service the wrong way. Could you guys please suggest how to deploy a windows service ?? (I have looked through net. All suggest building it and installing it from visual studios. But how to publish it is the thing which i need.)
Please help asap.
Possibly you built the setup project before uninstalling the preovious service. In that case you can't use the new setup to uninstall the service, since the setup won't be the same and can't be able to access the service installed.
You should try to go to a previous version of your project and uninstall the service and for the future unistall the service each time you're building your setup project.
This happened to me several times.
Run visual studio in debug mode, and in your properties of your service project goto tab build events in Post-Build event command line and add a -d so you can run your service without installing it, it will run as an console app
The LocalService account acts as a non-privileged user on the local computer, and presents anonymous credentials to any remote server. Use the other accounts with caution, as they run with higher privileges and increase your risk of attacks from malicious code.
If your service application will not install correctly, check to make sure that the ServiceName property for the service class is set to the same value as is shown in the installer for that service. The value must be the same in both instances in order for your service to install correctly.
NoteNote
You can also look at the installation logs to get feedback on the installation process.
You should also check to determine whether you have another service with the same name already installed. Service names must be unique for installation to succeed.
STUPIDITY PERSONIFIED
As i told i was deploying my service. So this published code had a "setup.exe" file to it. Now I had already created a setup project for the windows service , which i was using for the installing , uninstalling . And i din't know (These words needs courage !!) that msi file created is required to install the windows service. So as i got through the folder structure of the setup project. I came across the .msi file . And hence the problem got solved. The Main problem was :
Me not knowing to use setup projects
And I confused setup.exe with the published windows service with the setup of windows service.
I am really sorry for stealing bandwidth off your precious time. Thanks to all for the valuable inputs.

Categories