Home > .NET Development > Easily Uninstall and Install Windows Services with batch file

Easily Uninstall and Install Windows Services with batch file

I have spent some time editing a windows service after installing (and uninstalling) it for several times and I have to admit that this consumes time on the command line tool, so I have written a batch file to stop the service, uninstall it, install it, and start it again, and all what i need to do is to run the batch file.

Paste the following lines in a file.txt, replace the service name and the service path to match yours, and rename the file to file.bat.

@ECHO Stopping service..
net stop AlertsService
@ECHO service stopped.
@ECHO Uninstalling Service…
@SET PATH=%PATH%;C:Program FilesMicrosoft Visual Studio 9.0VC
“C:WINDOWSMicrosoft.NETFrameworkv2.0.50727installutil” -u “C:DebugAlertsWindowsService.exe”
@ECHO Uninstall Done.
@ECHO Reinstalling..
“C:WINDOWSMicrosoft.NETFrameworkv2.0.50727installutil” -i “C:DebugAlertsWindowsService.exe”
@ECHO Install Done.
@ECHO Starting Service..
net start AlertsService

Advertisements
Categories: .NET Development
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: