Deploying Windows Services in VB2005 express

Scriptor

New member
Joined
Apr 30, 2006
Messages
2
Programming Experience
Beginner
I recently created a simple windows service to try it out. When I publish it and try to run it, it gives me an error saying I need to use installutil.exe to install the service and start it with something else.

can anyone tell me what I need to do to turn it all into a functioning and working windows service, especially how to use the installutil.exe and so on.

Note: I am using vb2005 express edition and got the template from the web.
 
Last edited:
I too found a windows service project template for VS2005 Express at Planet Source Code this address Windows Service Project Template

What's missing is the service installers. Basically you have to add a class that inherits from System.Configuration.Install.Installer, then add a
ServiceProcessInstaller and a ServiceInstaller and configure them.
I have attached such class that can be included in the service project. Just add this with "Add Existing" and rebuild.

ClickOnce publish does not support this kind of installation. All that is needed is to deploy the windowsservice.exe file and run the installutil.

Install and uninstall like this, the utility is located in \WINDOWS\Microsoft.NET\Framework\v2.0.50727 folder:
InstallUtil.exe windowsservice.exe
InstallUtil.exe -u windowsservice.exe
 

Attachments

  • ProjectInstaller.zip
    817 bytes · Views: 228
thanks, although I had found a simlar template a few days back, the resonse is well appreciated.

but just in case anyone knows, is there a way to create an installer for a service that doesn't require instalutil to be run manually, so that it'd be easier to distribute?
 
VB Express was never intended to be used to create an distribute Windows services. If they omitted the project template it's no surprise that the facility to distribute is not there either. You could use a third-party tool like Inno or NSIS to create an installer I'm sure.
 
VB Express Service qustions

I appreciate the posts in this thread to date. However, I'm having some issues & need some assistance (I'm a system & DB admin, not a VB.net technician). I'm trying to replace some of my VB scripts with Windows Services, so that I have better control over them. I'm starting with a script to copy EventLogs. I wrote & tested the process in a VB Form, then copied the processing to a new Service built as described in the posts above.
First Problem was the name of the service - myWinService. I want the service name the same as the executable - CopyLogsToDatabase. I changed the Name & ServiceName in the Properties to this value - now the service will not install, and the InstallUtill says it's trying to use the same name myWinService. I've uninstalled myWinService, but still get the same error. Also, I get the following unhelpful error when running InstallUtil:
'An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: The specified service has been marked for deletion'.

Thanks in advance.

BigSam
 
myWinService is the ServiceName set in the ServiceInstaller.

I think you get that error if you didn't stop the service before unregister it, you would then have to restart machine before registering a new service with the same name.

Check with/Use Control Panel>Administrative Tools>Services to start/stop services and review what service is installed. (Refresh to update)
 
Back
Top