Windows Service Automatic Start
-
I am developing a windows service in VB .NET. I currently am using a START button on a windows form (separate application) to start the service. I would like to avoid having a separate application and, instead, have the service automatically start at installation. Does anyone know how I might accomplish this? Thanks for your time.
-
I am developing a windows service in VB .NET. I currently am using a START button on a windows form (separate application) to start the service. I would like to avoid having a separate application and, instead, have the service automatically start at installation. Does anyone know how I might accomplish this? Thanks for your time.
hi my dear friend, always Try avoiding a user interface, inputs and message boxes in the service application or for starting the service. To make your service to start Automatically during the start up of windows in the serviceinstaller Open the service.vb design window, right click on it and select Add Installer option, which will add an installer project (called ProjectInstaller.vb) with two controls -- ServiceProcessInstaller1 and ServiceInstaller1 -- to our existing project. Open ProjectInstaller.vb, select the ServiceInstaller1 control, and open the property window. Change the StartType property to automatic if you want to start the service automatically during the OS Start Up. HAPPY PROGRAMMING! ;) With regards, Barathan.K Barathan.K
-
hi my dear friend, always Try avoiding a user interface, inputs and message boxes in the service application or for starting the service. To make your service to start Automatically during the start up of windows in the serviceinstaller Open the service.vb design window, right click on it and select Add Installer option, which will add an installer project (called ProjectInstaller.vb) with two controls -- ServiceProcessInstaller1 and ServiceInstaller1 -- to our existing project. Open ProjectInstaller.vb, select the ServiceInstaller1 control, and open the property window. Change the StartType property to automatic if you want to start the service automatically during the OS Start Up. HAPPY PROGRAMMING! ;) With regards, Barathan.K Barathan.K
Thanks for your reply. Actually, I do have the service automatically starting during the OS start-up using the method you described. What I want to do is have the service automatically started right after installation (without requiring a reboot). I was eventually able to accomplish this by putting the following code in the ProjectInstaller.vb file. The program "MyApp" is a console application that starts, stops, pauses, etc. the service using various command parameters (in this case, "/start,MyService"). 'Auto-start the service after installation. Dim psInfo As New System.Diagnostics.ProcessStartInfo("C:\Program Files\MyApp.exe", "/start,MyService") psInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden Dim myProcess As Process = System.Diagnostics.Process.Start(psInfo) Thanks, Todd_S