Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Windows Services for VB.NET Developers  »  Deployment
 »  Home  »  Windows Development  »  Windows Services for VB.NET Developers  »  Deployment
Windows Services for VB.NET Developers
by Scott Rutherford | Published  12/20/2005 | .NET Newbie Windows Development | Rating:
Scott Rutherford
Scott Rutherford is a consultant and .NET developer who has developed Enterprise business applications in many fields including Restaurant, Market Research, Automotive, and Analytical Chemistry. He is an Microsoft Certified Professional with the .NET Platform. 

View all articles by Scott Rutherford...
Deployment

Once your Service and Worker classes are complete, compile the project to get your service EXE.

To install the service on a PC you can use the .NET frameworks tool InstallUtil.exe, found in the frameworks system directory.

You can copy the code listed here into a BAT file for simple DOS installation.

To uninstall just put a –U flag after the InstallUtil.exe call
(i.e. %FIRSTPART%%DOTNETVER%%SECONDPART% -U %PROG%).

[DOS]
@echo off
SET PROG="C:\EmptyService.exe"
SET FIRSTPART=%WINDIR%"\Microsoft.NET\Framework\v"
SET SECONDPART="\InstallUtil.exe"
SET DOTNETVER=2.0.50727
  IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
SET DOTNETVER=1.1.4322
  IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
SET DOTNETVER=1.0.3705
  IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
GOTO fail
:install
  ECHO Found .NET Framework version %DOTNETVER%
  ECHO Installing service %PROG%
  %FIRSTPART%%DOTNETVER%%SECONDPART% %PROG%
  GOTO end
:fail
  echo FAILURE -- Could not find .NET Framework install
:end
  ECHO DONE!!!
  Pause

Some deployment hints:
  • Elevate NTFS on the service EXE file to ensure it is not replaced by another similar named exe which will now run under the configured security context.
  • To avoid a reboot after install/uninstall unlock resources used by your service, which includes closing files, closing the Windows Service Manager, etc. Sometimes adding an IISRESET line to the install script is helpful.

Now your service is installed. Start it and Stop it from the Service Manager and use the Event Log Viewer to view its output.



How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:3.70050761421322 out of 5
 197 people have rated this page
Article Score87536
Sponsored Links