Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

how to install windows service using command prompt or install/uninstall .NET windows service

Jun 14, 2011
Introduction:

Here I will explain how to install windows service and how to start the windows service in our local machine.

Description:

In previous article I explained clearly how to create windows service and how to run windows service in scheduled intervals. Now I will explain how to install windows service in our system.

To install windows service in your follow these steps

Start --> All Programs --> Microsoft Visual Studio 2008 --> Visual Studio Tools --> Open Visual Studio Command Prompt

After open command prompt point to your windowsservice.exe file in your project
Initially in our command prompt we are able to see path like this

C:\Program Files\ Microsoft Visual Studio 9.0\VC > 

This path is relating to our visual studio installation path because during installation if you give different path this path should be different now we can move to folder which contains our windowsservice.exe file. After moving to exe file exists path my command prompt like this

After moving to our windowsservice.exe contains folder now type 

Installutil windowsservicesample.exe (Give your windows service exe file name) and now press enter button.

After type Installutil windowsservicesample.exe file that would be like this

After that the service will install successfully in your system.

Now I have question do you have idea on how to see installed windows services and how to start our windows service if you have idea good otherwise no need to panic just follow below steps

Start --> Control Panel --> Open Control Panel --> Select Administrative Tools --> Computer Management --> Services and Applications --> Services --> Open services

Now check for your windows service name and right click on that and select option start your windows service has started successfully 

That would be like this 

 
If we want to uninstall the installed windows service you just point to your service same as what I explained previously and type statement installutil /u and your service name
Installutil /u windowsservicesample.exe

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

60 comments :

Mehtab Ali said...

That's too Good Suresh...

Anonymous said...

Thanks dude

Anonymous said...

Excellent Blog...

Anonymous said...

Hi Suresh it shows error by the time of installing :exception occur during rollback phase of installation

Suresh Dasari said...

hi,
i think that problem because of permissions problem. Please check the error message in your command prompt and try it

Anonymous said...

ok sure I will check that.
Actully first time I am working on windows service so dont no in depth but your artical is very informative for like me (beginners):)
thanks again

Abhijeet said...

Simple ,yet efficient blog really good article for understanding

sonia said...

Very nice Tutorial.It help me too Much.But i Didnt understand something here.Can u tell me abt OnElapsedTime function here.Cant we write whole code in timer_tick event.,

forex options said...

Hi..I have problem in installing the window service
when i type the command installutil myservicename.exe in command prompt than error is coming
so pls suggest me..

bad boy said...

hello sir,
your tutorial was really helped me alot .can u tell me how can use windows service with Wpf application? plz share some link thnx
sumit

suhail said...

The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.

plz suggest me for above instation failling
thanks

suhail said...

hello suresh
The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.

plz suggest me for above instation failling
thanks

Suresh Dasari said...

@Suhail..
i think that problem because of login details please check do you have admin rights to install windows service or not and give your system username and password during install windows service correctly

suhail said...

thank u sir for your valuable responce ur tutarial is very helpful .the problem was due to account type, now the problem is i have made an installer for the servie.the service works good for mannually. but i want start it automatically when service instal and stop when service uninstall
thanks

SREE RAMA MURTHY said...

Can any help me in this issue.. i got c# program which should do accordingly
The installer should have the following when launched
Ask the user to enter
1. company URL
2. User ID
3. Password
Once the validation is complete, it should store the company URL in a properties file, which has to be picked up by the service to send information to our server.
4. The user should have the option to stop my service from the system tray and start - programs

shalim008 said...

Thank u. Your tutorial is so helpful. Thanks again for your tutorial.

Anonymous said...

Hello Suresh,
Excellent tutorial. Please need some help for Starting the Service. I get:
"Windows could not start the SchedulledService Service on Local Computer. Error 5: Access denied"
This happens in W7 and also with XP. I opened the cmd box and the Service window as Admin (Run as Administrator).
Appreciante a hint
Thanks
Xavier

Unknown said...

hi suresh, i did step by step but while installing WS in VS2010 in does not install. it give error 'installation failed,rollback performed'
can you solve my query plz

Anonymous said...

Hi suresh,
it was really a nice article.
i also want to know that how can i connect window service to my database using app.config and then make an exe setup for my window service
thanks

Pallavi said...

Hi Suresh,

After done with installation ,I wanted to start windows service and followed the steps as you said. But, I'm not able to find my windows service name in Services !!
What might have gone wrong? Please help.

Regards,
Pallavi

Anonymous said...

hello suresh can u tell me how to install service in server system where it is in cloud and we dont have vs prompt over there, how to install using general command prompt

Anonymous said...

Thanx.. It's working...

Shahid said...

Thanks a lot Suresh Bhai...

Anonymous said...

thanx suresh

Anonymous said...

...........HELP HELP HELP HELP............

I am getting message while installing Windows Service. Message is " ACCESS IS DENIED"

Please help

Thanx in advance

Upendra said...

Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.


Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the E:\work Area\WinServiceSample\WinServic
eSample\bin\Debug\WinServiceSample.exe assembly's progress.
The file is located at E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\
WinServiceSample.InstallLog.
Installing assembly 'E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\Wi
nServiceSample.exe'.
Affected parameters are:
logtoconsole =
logfile = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinService
Sample.InstallLog
assemblypath = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinSe
rviceSample.exe
Installing service ScheduledService...
Creating EventLog source ScheduledService in log Application...

An exception occurred during the Install phase.
System.Security.SecurityException: The source was not found, but some or all eve
nt logs could not be searched. Inaccessible logs: Security.

The Rollback phase of the installation is beginning.
See the contents of the log file for the E:\work Area\WinServiceSample\WinServic
eSample\bin\Debug\WinServiceSample.exe assembly's progress.
The file is located at E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\
WinServiceSample.InstallLog.
Rolling back assembly 'E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\
WinServiceSample.exe'.
Affected parameters are:
logtoconsole =
logfile = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinService
Sample.InstallLog
assemblypath = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinSe
rviceSample.exe
Restoring event log to previous state for source ScheduledService.
An exception occurred during the Rollback phase of the System.Diagnostics.EventL
ogInstaller installer.
System.Security.SecurityException: The source was not found, but some or all eve
nt logs could not be searched. Inaccessible logs: Security.
An exception occurred during the Rollback phase of the installation. This except
ion will be ignored and the rollback will continue. However, the machine might n
ot fully revert to its initial state after the rollback is complete.

The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.

Upendra said...

i am getting above error while installing services..

Unknown said...

i am also getting above error and also tried to installutil.exe in the directory where my webservice allready is, but getting same error...

vikas chhabra said...

Thanks Suresh..Today I learn a lot from you. please continue to share gud things with us.

Anonymous said...

same error as above.please help

Pratik Menon said...

Please help with the error of transaction being rollbakc.i have given full control.stil issue persists...Help asap...plzz

Anonymous said...

Really super suresh.....

Sam said...
This comment has been removed by the author.
David Billa said...

@Upendra Patel and @JITENDRA YADAV,

Try to run the Open "Visual Studio Command Prompt" with admin mode, re-run the InstallUtil command & see if you are still seeing that error.

Unknown said...

Hi Suresh,

I'm getting an error while installing the .exe file into my local machine.

ERROR:'installutil' is not recognized as an internal or external command,
operable program or batch file.

Plz help me out in fixing this bug.

Thank you

Anonymous said...

hi suresh,

The service is not installed, because i didnt create setup for it, Can u explain how to create setup ?

vikram singh said...

sir,
please tell me can it applicable on hosting site if yes then how?

sakthideveloper said...

how can we solve this error?

C:\sakthi\DemoService\DemoService\bin\Debug>installutil DemoService.exe
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.


Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:\sakthi\DemoService\DemoService\bin\D
ebug\DemoService.exe assembly's progress.
The file is located at C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.I
nstallLog.
Installing assembly 'C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.exe
'.
Affected parameters are:
logtoconsole =
logfile = C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.InstallLog
assemblypath = C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.exe

An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: Access is denied

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\sakthi\DemoService\DemoService\bin\D
ebug\DemoService.exe assembly's progress.
The file is located at C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.I
nstallLog.
Rolling back assembly 'C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.e
xe'.
Affected parameters are:
logtoconsole =
logfile = C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.InstallLog
assemblypath = C:\sakthi\DemoService\DemoService\bin\Debug\DemoService.exe
An exception occurred during the Rollback phase of the System.ServiceProcess.Ser
viceProcessInstaller installer.
System.NullReferenceException: Object reference not set to an instance of an obj
ect.
An exception occurred during the Rollback phase of the installation. This except
ion will be ignored and the rollback will continue. However, the machine might n
ot fully revert to its initial state after the rollback is complete.

The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.

uma said...

After successful completion of services it cannot be appeared in services menu...

please tell me the solution...

Anonymous said...

'Documents' is not recognized as an internal or external command,
operable program or batch file. can you tell me what;s the probleam

Unknown said...

nice articl

Unknown said...

it is not getting Install in local Machine Will u please help me suresh

Anonymous said...

I tried this in windows 7 64 bit machine with Run as administrator option , i am getting this error :
An exception occurred during the Install phase.
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security. The Rollback phase completed successfully.
other servers this is working fine, do we have to change any settings to install this in windows 7 server

Unknown said...

while you are running in command prompt run the cmd as administrator then u will not face th problems of roll back issue

choose the Account type as the User type then give your system credentials and u can run the service

Anonymous said...

hi Suresh.. your article is really so useful but I am getting problem while installing the window service. it gives the error of unrecognized internal and external command. please help

Anonymous said...

Very Useful

sudheer said...

I am getting an issue in installation -- I ran the command prompt in admin mode and ran the below command

C:\WinService Sample\WinService Sample\bin\debug>installutil WinService Sample.exe

I am getting Error -- 'installutil' is not recognized as an internal or external command, operable program or batch file

PLEASE HELP --- I have installutil on my machine under :\WINDOWS\Microsoft.NET\Framework\v4.0.30319

Anonymous said...

Hi man,
How to install on any one user account with write permissions on event log.I am getting security related exception are System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.

Anonymous said...

Hello to everyone,

Who getting security base error, please run you command prompt in run as administrative mode.It solve issue.

Thanks

sumi said...

Thank you Suresh....very nyc article. Keep writing such articles.

sumi said...

For checking the running status of ur service, u can also simply write services.msc on 'Run' and search ur service.

Unknown said...

Thank u so much This s amazing man.

Anonymous said...

Thanks for providing this solution.
i runned Visual studio command prompt as Administrator and it works successfully.

Murali said...

Hi,

I am also getting same issue. I ran as administrator but still getting same problem. Please help me.

Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.


Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the E:\work Area\WinServiceSample\WinServic
eSample\bin\Debug\WinServiceSample.exe assembly's progress.
The file is located at E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\
WinServiceSample.InstallLog.
Installing assembly 'E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\Wi
nServiceSample.exe'.
Affected parameters are:
logtoconsole =
logfile = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinService
Sample.InstallLog
assemblypath = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinSe
rviceSample.exe
Installing service ScheduledService...
Creating EventLog source ScheduledService in log Application...

An exception occurred during the Install phase.
System.Security.SecurityException: The source was not found, but some or all eve
nt logs could not be searched. Inaccessible logs: Security.

The Rollback phase of the installation is beginning.
See the contents of the log file for the E:\work Area\WinServiceSample\WinServic
eSample\bin\Debug\WinServiceSample.exe assembly's progress.
The file is located at E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\
WinServiceSample.InstallLog.
Rolling back assembly 'E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\
WinServiceSample.exe'.
Affected parameters are:
logtoconsole =
logfile = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinService
Sample.InstallLog
assemblypath = E:\work Area\WinServiceSample\WinServiceSample\bin\Debug\WinSe
rviceSample.exe
Restoring event log to previous state for source ScheduledService.
An exception occurred during the Rollback phase of the System.Diagnostics.EventL
ogInstaller installer.
System.Security.SecurityException: The source was not found, but some or all eve
nt logs could not be searched. Inaccessible logs: Security.
An exception occurred during the Rollback phase of the installation. This except
ion will be ignored and the rollback will continue. However, the machine might n
ot fully revert to its initial state after the rollback is complete.

The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.

Anonymous said...

When i clicked on start i got this dialog box.. " The scheduledService service on local computer started and then stopped. some service stop automatically if they are not in use by other services or program ". I am new with the topic.. Please help..

Anonymous said...

Exellent Work! Keep it up

jamsheeeeer said...

good explanation..............thankz

Unknown said...

Try to install with CMD (Run as Administrators) at system32 folder.

Anonymous said...

Good It was really helpful. Thanks

Anonymous said...

jkl

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.