Wrox Programmer Forums
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 8th, 2007, 11:29 AM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Autostart a Windows Service

I am making an installshield installer and install a service during the install using installutil.exe. I would like to make this service autostart when windows boots up, is this possible? If so, how?

I thought this was more of a .net topic than an installshield one.

Thanks,

James

 
Old August 8th, 2007, 12:03 PM
Authorized User
 
Join Date: Sep 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Normally, when creating a windows service in .NET you use an ServiceInstaller to install the service. The ServiceInstaller contains a property named StartType (http://msdn2.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.starttype(v s.80).aspx). You can set this property to one of the ServiceStartMode values (http://msdn2.microsoft.com/en-us/library/system.serviceprocess.servicestartmode(VS.80).aspx ).

So in your case, you need to set it to Automatic which indicates that the service needs to be started automatically.

Hope this helps.

Greetz,

Geert

http://geertverhoeven.blogspot.com
 
Old August 8th, 2007, 02:47 PM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Many thanks for your reply. It is one of our other developers that has worked on the service and I am responsible for making the installer.

I've been doing some research on how Windows Services work and am I right in thinking that the installutil.exe is how all services are installed onto Windows (it's not a case of placing an exe onto the hard drive as in an application?)?

If so, am I right in assuming that there aren't any parameters that can be passed into installutil.exe that can make it autostart and that the only way to do this is by setting the ServiceStartMode property to Automatic in .net?

 
Old August 13th, 2007, 08:48 PM
Registered User
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In .NET you create a class that implements ServiceInstaller I believe and installutil looks for this when installing your service. In the ServiceInstaller, you specify the start type and so on. So you do not specify start type in the service but in the service installer. In other words you are correct, the installutil does not explicitly have an option to set the start mode.

Also installutil is used for installing .NET services onto a Win32 machine that supports services (WinNT/2k/XP/Vista). Installutil will not install C++ executables for example. See http://msdn2.microsoft.com/en-us/lib...95(vs.80).aspx for usage.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Impersonate with windows service for Service A/C vinod_yadav1919 C# 0 October 18th, 2008 02:29 PM
Windows service exarkuun General .NET 0 September 7th, 2007 10:19 AM
Windows Service everest C# 1 March 8th, 2007 01:10 PM
Accessing Windows service from a windows app sajid08 C# 1 October 6th, 2006 10:25 AM
Windows Service r_ganesh76 General .NET 4 January 11th, 2005 05:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.