WCF Windows Service Deployment

1 Dec

I recently started work on a personal project to make a WCF Windows Service using the following tutorial: [1]. I soon realised that I would need to write a batch file to not be hugely disadvantaged by manual deployment. I also wanted my deployment batch scripts to be re-useable by other developers on the project.

The batch files I came up with were:



:: Known issues –
:: 1) if services window is open (ie the one when u start->run->services.msc) then the process will not close. You must close this window.
:: 2) if you don’t do a clean build then it will just install old version of service. Make sure you uninstall then do a clean build.


SET projectDirectory=%CD%

cd /d “%WinDir%\Microsoft.NET\Framework\v4.0.*”

SET net4Path=%CD%


%net4Path%\installutil “%PROJECTDIRECTORY%\bin\Debug\OrderServices.exe”

net start OrderServices




SET projectDirectory=%CD%

cd /d “%WinDir%\Microsoft.NET\Framework\v4.0.*”

SET net4Path=%CD%

net stop OrderServices

%net4Path%\installutil /u “%PROJECTDIRECTORY%\bin\Debug\OrderServices.exe”


Reinstall.bat (untested):

@echo off
CALL Unistall.bat
CALL Install.bat

Those batch files assume the following file structure in your service project:



The following link adds reference information as to how to forcefully play with services with the SC command: http://ss64.com/nt/sc.html


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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: