How to install a .NET windows service without InstallUtil.exe vb.net
Asked Answered
A

3

5

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?

Arachne answered 30/1, 2012 at 19:46 Comment(0)
A
9

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.

Adhern answered 30/1, 2012 at 19:52 Comment(7)
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?Arachne
or should i look to sintall via a .bat fle?Arachne
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/…Adhern
You Sir, are a genius! Thanks for the link, ill have a read through now!Arachne
So not true... But thanks for the compliment, and you're welcome for the link.Adhern
I seem to be struggling with the part regarding the installing method. I only need to create a piece of code that sets one variable. i have asked it in another question as i feel the links on this question make for easy reading and i dont want to complicate matters. bit.ly/wHA2dtArachne
The link is longer valid. I found an archive at the following location: betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/…Sammer
L
4

Why do you want to avoid installutils?

You could try using the sc command, as in 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>
Leaven answered 30/1, 2012 at 19:58 Comment(2)
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.Adhern
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.Allusive
H
2

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.

Handsomely answered 30/1, 2012 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.