Sebastian's WebLog

.NET Architecture & Technologies

Two Lines of Code - Installing Windows Services w/o InstallUtil.exe

After long time of browsing the web I finally found an article describing how to install/uninstall a service with only two lines of code.

Install:

String []installParams= {filename};
System.Configuration.Install.ManagedInstallerClass.InstallHelper(installParams);

Uninstall:

String []installParams= {"/u", filename};
System.Configuration.Install.ManagedInstallerClass.InstallHelper(installParams);

You have to add System.Configuration.Install reference manually.

Please have a look at Roaan's article at SA Developer http://www.sadeveloper.net/viewarticle.aspx?articleID=49 for further information about logging and stack output.

Comments

afsari said:

Hi.. I have tried this but i am getting FileNot Found exception.

# February 15, 2008 11:30 AM

John said:

You need to specify the full path to the file.

# March 14, 2008 2:33 PM

Sanjay Choubey said:

give appropriate url

# March 25, 2008 1:43 AM

Joseph said:

Thanks, was very helpful

# March 31, 2008 3:07 PM

Haider said:

Where I will write this code, in a new service project or in my own service. Please ...

# July 23, 2009 1:01 AM

Ainsworth said:

Pretty element of content. I simply stumbled upon your blog and in accession capital to claim that I

get actually loved account your blog posts. Anyway I will be subscribing for

your augment and even I fulfillment you get right of entry

to constantly quickly.

# March 27, 2013 9:41 PM

Koehler said:

Hello there! Do you know if they make any plugins to protect against hackers?

I'm kinda paranoid about losing everything I've worked hard on.

Any recommendations?

# April 4, 2013 11:52 PM

Novotny said:

Hi there! I'm at work surfing around your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Keep up the outstanding work!

# April 5, 2013 11:15 AM

Ferreira said:

Appreciation to my father who shared with me regarding this

blog, this web site is in fact remarkable.

# April 5, 2013 7:18 PM

Greathouse said:

Hello friends, fastidious piece of writing and nice arguments commented at this

place, I am in fact enjoying by these.

# April 8, 2013 4:11 PM

Reiss said:

Magnificent items from you, man. I have be aware your stuff prior to and you are just too

excellent. I actually like what you've acquired right here, certainly like what you are stating and the best way through which you are saying it. You make it enjoyable and you continue to take care of to keep it sensible. I can not wait to learn much more from you. That is really a terrific site.

# April 10, 2013 2:01 PM

Faulk said:

Hello, Neat post. There's an issue along with your site in internet explorer, could check this? IE still is the market leader and a good part of other folks will omit your great writing due to this problem.

# April 11, 2013 5:38 AM

Askew said:

When someone writes an post he/she keeps the

image of a user in his/her brain that how a user can know it.

Therefore that's why this post is outstdanding. Thanks!

# April 11, 2013 5:06 PM

Parsons said:

Hi, the whole thing is going well here and ofcourse every one is sharing facts, that's truly fine, keep up writing.

# April 11, 2013 11:39 PM

Ashmore said:

Excellent blog right here! Also your site a lot up very fast!

What host are you the use of? Can I am getting your affiliate link in your host?

I want my web site loaded up as quickly as yours lol

# April 13, 2013 7:23 AM

Arreola said:

Great blog you have got here.. It's difficult to find quality writing like yours nowadays. I seriously appreciate individuals like you! Take care!!

# April 17, 2013 2:52 PM

Glynn said:

It's very easy to find out any matter on web as compared to textbooks, as I found this paragraph at this website.

# April 18, 2013 6:44 PM

Day said:

Pretty nice post. I just stumbled upon your blog and wished to say

that I have truly enjoyed surfing around your blog posts.

After all I'll be subscribing to your feed and I hope you write again very soon! How To Take Creatine Pills - creatine \u0022effects of creatine\u0022 - creatine powder 1000g creatine fuel twinlab side effects - micronized creatine optimum nutrition review - does creatine work for hardgainers

# May 6, 2013 6:45 PM

Rohr said:

Great goods from you, man. I've understand your stuff previous to and you are just extremely wonderful. I really like what you have acquired here, really like what you are stating and the way in which you say it. You make it enjoyable and you still take care of to keep it smart. I cant wait to read much more from you. This is actually a wonderful web site.

# May 8, 2013 8:14 PM

Lyles said:

Hurrah! In the end I got a blog from where I be able to actually get useful

facts regarding my study and knowledge. rippln - rippln

- rippln mobile

# May 11, 2013 1:01 AM

Carmona said:

Hurrah! After all I got a weblog from where I be capable of genuinely get useful

information concerning my study and knowledge.

# May 26, 2013 3:36 AM