Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

16 August 2012

What To Do When Windows Service Will Not Delete


When a service is removed from any Microsoft Windows operating system, to date, the system must be rebooted, to completely remove the service.  After restarting the operating system, the service entry should be deleted.  If the service still appears in the Services MMC, or a "specified service already exists" error is displayed upon installing a fresh copy of the service, you'll probably need to tweak the registry, to manually remove the service key.

BE VERY CAREFUL, WHEN EDITING THE SYSTEM REGISTRY!

  1. Execute regedit.exe
    1. Windows Vista/2008 and newer: type "regedit" in the start menu search box
    2. Older versions: click the "Run" option, located in the start menu
  2. Press the Enter key, to launch
  3. Back up your registry
    1. Click file menus: File > Export...
    2. Select a location to save the registry backup file
    3. Click the Save button
  4. Using the tree menu, navigate to: HKEY_LOCAL_MACHINE > SYSTEM> CurrentControlSet > services
  5. Locate the child node of "services" that matches the service you need to delete
  6. Press the delete key on the keyboard -- a delete confirmation appears
  7. Click the Yes button, in the delete confirmation -- the registry key is deleted
  8. Close the registry editor

How To Work Around "Specified Service Already Exists"

If you have ever created a Windows Service, you are likely familiar with the "specified service already exists" installation error message.  Most developers encounter this situation after making code changes, and attempting to install the updated service, for testing.  The problem is that Windows services can not be removed without a system reboot.

The solution is simple.  Install the service for testing, only once.  To test newly-compiled changes to the service:

  1. Stop the service
  2. Copy new files into the service installation directory, overwriting the old ones
  3. Start the service

Easy!

As always, use unit tests, to test code, instead of testing through execution.  There is little excuse to not test code, these days.  To expedite testing and TDD, I suggest installing NCrunch for Visual Studio (http://www.ncrunch.net/).

29 December 2010

Advanced C# Windows Service Installation

Click this link, to download source code.
Today, I'm going to show you how to efficiently create Windows Services and deployment projects, using C# in Visual Studio 2010.  These techniques illustrate methods of centralizing key information about the services included in the project, to prevent typos and other mistakes attributed to setting similar properties in decentralized locations.

This example is especially useful for projects that contain several services that use common code bases.  For example, I have a service suite that monitors several FTP drop directories on a server.  Each watcher performs different, custom actions; but, 90-95% of the code is common to all services.  For this and other reasons not discussed here, it makes sense to simply package all services in one project.  The more popular alternative is to create a common library, install to GAC, and create individual service solutions.

The bottom line is that I wanted to simplify management and deployment.  To simplify service registration, I created a "ServiceInfo" class attribute into which all service information is entered, instead of mucking about in several ProjectInstaller files.  View the full article, to get source code and a complete walk-through.

UPDATE 13 MAR 2012: I updated the code sections, to use formatted HTML, instead of using JavaScript code coloring.  The code was formatted a bit, for fit, and to make the LINQ more efficient.  Therefore, the code in the download won't be exactly the same, but it works.

16 November 2010

Extract Files From ISO Images Without Additional Software

I decided to write reports for SQL Reporting Services.  They are fast, look great, and are oh-so-easy to access via the Web interface.  However, I discovered that Visual Studio versions must be paired to the SQL Server version.  I needed to install Visual Studio 2005, but had only the .ISO CD-ROM image available, and was unable to install software to extract the files.

08 September 2010

Mouse Suites Aren't So Sweet

Visual Studio, Microsoft Office, and many other applications making use of docked windows are subject to the rigors of "helpful" mouse software suites, kindly loaded by computer manufacturers.  Such manufacturers include HP / Compaq, IBM / Lenovo, and others.

09 August 2010

Mouse Scroll Wheel Issues With Visual Studio and Office

I encountered an old foe, on the workstation of my day job, after installing Visual Studio 2010 Premium.  Moving the mouse scroll wheel normally causes my C# code window to scroll vertically.  However, this particular computer randomly decides vertical scrolling is simply too mundane, and starts scrolling tool windows, instead.  I have experienced this problem in the past, after installing Visual Studio 2003 on a HP workstation.  The issue was resolved after I updated the mouse drivers to use the standard Microsoft Windows mouse driver.  The mouse worked beautifully!  But, what was the cause of the problem?