Cómo instalar un servicio de Windows .NET sin InstallUtil.exe vb.net

I have created a windows service in vb.net. Is there anyway i can create an installation for it that does not require installutil to be used?

preguntado el 30 de enero de 12 a las 19:01

3 Respuestas

Installutil is necessary, but to make things easier, you can create a Setup project, so that you simply run an .msi to install the service. (This uses installutil under the hood, but it greatly simplifies installation.)

One walkthrough is here: http://support.microsoft.com/kb/816169

And another is here: http://msdn.microsoft.com/en-us/library/zt39148a(VS.80).aspx

The main difference between the two is the amount of code in the samples. They both walk you throuigh the same process.

The articles linked to are old, but still apply in VS2010. I used the second article to walk through the process for a VS2010 service just last week.

Respondido el 30 de enero de 12 a las 23:01

Thanks for the walkthrough. I also used the second article with great success. However within my service i have a variable called filepath, which determines the output location of the files my service creates. Is there anyway i can get the user to be able to type in the location they want? - Simon

or should i look to sintall via a .bat fle? - Simon

You can do it if the values are in the .config file. There's a tutorial here that shows how to modify app.config values in a Setup Project install scenario. I haven't used it, but it look spromising. raquila.com/software/… - David

You Sir, are a genius! Thanks for the link, ill have a read through now! - Simon

So not true... But thanks for the compliment, and you're welcome for the link. - David

Why do you want to avoid installutils?

Podrías intentar usar el sc comando, como en sc create ...

EDIT: Here's an MSDN page for it: http://support.microsoft.com/?kbid=251192

DESCRIPTION:
        Creates a service entry in the registry and Service Database.
USAGE:
        sc <server> create [service name] [binPath= ] <option1> <option2>...

OPTIONS:
NOTE: The option name includes the equal sign.
      A space is required between the equal sign and the value.
 type= <own|share|interact|kernel|filesys|rec>
       (default = own)
 start= <boot|system|auto|demand|disabled|delayed-auto>
       (default = demand)
 error= <normal|severe|critical|ignore>
       (default = normal)
 binPath= <BinaryPathName>
 group= <LoadOrderGroup>
 tag= <yes|no>
 depend= <Dependencies(separated by / (forward slash))>
 obj= <AccountName|ObjectName>
       (default = LocalSystem)
 DisplayName= <display name>
 password= <password>

Respondido el 30 de enero de 12 a las 23:01

That's a good one. I'd forgotten about that. I used that on my first service before I found out how to sue MSI files. This allows you to do things that you can't do with InstallUtil like setting the default username and password for the service to run under. +1. - David

pay special attention to the [binPath= ] there has to be a space between the = and the start of your path. This has got me numerous times. - AndyM

You can always do it with registry entries.
The keys are found in HKLM\SYSTEM\CurrentControlSet\services

The key name you create is the embedded name of the service on your service handler. The following values are relevant:

DisplayName = text that gets displayed in the services manager

ImagePath = FQ Filename of service executable

Start (DWORD) = startup type (3 = autostart)

DelayedAutoStart (DWORD) = (1 = delayed)

WOW64 (DWORD) = (0 = 64-bit app, 1 = 32-bit app)

ErrorControl (DWORD) = 0

ObjectName = {username} to run under (LocalSystem for system account)

There are lots of other values, but that should get you started.

Respondido el 31 de enero de 12 a las 02:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.