How to install a Windows service created in VC++ 6.0 - windows-services

I have a windows NT service (Maths.exe) created in VC++ 6.0.
I don't have the source code or Visual studio 6.0 installed on my machine.
Can anyone please let me know the command using which I can install the service in Service Control Manager (invoked using service.msc).
I want to control (start, stop) the service manually.
Thanks in advance.

To install a service, you can use the sc utility. The steps are:
Copy the executable and all its dependencies into a directory (%SYSTEMROOT%\System32 is perfectly valid).
Run as administrator of the computer the command:
sc create MathsService binPath= %SYSTEMROOT%\System32\Maths.exe type= own type= interact start= demand DisplayName= "My fabulous Maths service"
Where MathsService is the name of the service, the argument to binPath is the binary location and DisplayName argument is the name that shows on services.msc. The argument to start can be boot (not suitable for a service), system (not suitable for a service), auto (autostart), demand (on demand start, you have to start your service manually) or disabled (service will not start even manually).
In this example, i use type= own type= interact. This allows the service to interact with the desktop (for TCP/IP communications, for example).
Complete reference of sc sintaxis is available running sc. Also check http://support.microsoft.com/kb/251192

Related

How to Configure the Windows Service Release Tasks like Install TopShelf Windows Service in VSTS?

I am working on DevOps with VSTS. I created the simple windows service application using VS2015 for that I configured the release definition in VSTS by adding this tasks through this Windows Service Release Tasks.
I configured the Start Windows Services, Install (TopShelf) Windows Service and Stop Windows Services tasks successfully.
Configuration of Install (TopShelf) Windows Service
During release the above Stop and Install tasks are run successfully but Start task failed with the following error.
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: No such services: FirstService
Because the Install(TopShelf) Windows Service task will not be installed an windows service in machine. But it simply succeded.
I have the few questions like
what is the difference between Install(TopShelf) Windows Service and Install and Start Windows Service VSTS release tasks.
If I used the Install(TopShelf) Windows Service task, It works only if you have already existing windows service is running in virtual machine otherwise it will failed. But if I used the Install and Start Windows Service task, It will be installed new windows service in virtual machine. But I am unable to give Displayname and Description of the installed windows service.
They are two extensions created by 3rd party. So you can search them in the VSTS Marketplace and get the detailed information for them.
For your question:
Install(TopShelf) Windows Service
This is used to install Topshelf service which created with Topshelf framework.
Install and Start Windows Service
This is used to install the general Windows Service via Power-Shell or InstallUtli.
So if you just create a general Windows Service from VS. You should use the second one.
And usually, to set the Display Name and Description for a Windows Service, you need to do it in your code. Please refer to this question for details: What's the best way to set a windows service description in .net.

Virtuoso Windows service not getting created

As per the instructions in virtuoso-t --help:
To create a windows service 'MyService' using the configuration file c:\database\virtuoso.ini:
virtuoso-t +service create +instance MyService +configfile c:\database\virtuoso.ini
I ran
virtuoso-t +service create +instance my-virtuoso +configfile D:\SOFT\Virtuoso\database\my-virtuoso.ini
got
[Using my-virtuoso.ini in D:\SOFT\Virtuoso\database]
The Virtuoso_my-virtuoso service has been registered
and is associated with the executable d:\soft\virtuoso\bin\virtuoso-t.exe
Service not showing in Windows services and not accessible on the port.
Is there a way to register a Virtuoso service on Windows 7?
BTW, OpenLink people (as I am pretty sure you are reading this), your instructions say To create a windows service 'MyService' but the result of the command run reports equivalent to Virtuoso_MyService. Might want to correct that in your next release, in addition to the actual service creation or maybe the instructions.
Thanks for the flag on the incorrect -? output. There are a few things that have changed and not been reflected properly there. That will be fixed.
One of these is that you should find the Service is listed in the control panel as OpenLink Virtuoso Server [MyService], which Windows knows as Virtuoso_MyService, and Virtuoso knows as MyService -- so the -? output should show --
To start this service in the command-line, use
sc start Virtuoso_MyService
or
virtuoso-t +service start +instance MyService
To work with this service in the Services or Component Services control panel, look for OpenLink Virtuoso Server [MyService].
Creating the Service does not start it; that's why it's not listening.
I have tested and confirmed all of the above on Windows 7, with both Open Source and Commercial Edition builds of version 7.2.4.2 (07.20.3217).

Create installer with Installshield that installs Windows Service

I have a windows service that installs itself by executing it in a cmd with the command line --install. This service also knows how uninstall itself by passing the --uninstall param in a cmd.
I need to create a MSI installer that installs this service and start it. I have tried by using Components in Installshield and using Custom Actions but not getting the rights results either way.
I need some help here. Thanks
Please see my answer under Wix installer to replace INSTSRV and SRVANY for user defined service installation
The WiX ServiceInstall and ServiceControl elements are abstractions for the underlying Windows Installer ServiceInstall and ServiceControl tables. InstallShield uses this same feature but instead of authored as XML it's authored in the components view under the advanced settings | services area of the component.
In general it's not a windows installer best practice to call a custom action to register the service. Instead figure out the details being done by the --install command and author them natively into these tables using InstallShield.
Installing, Controlling, and Configuring Windows Services

Actual meaning of windows services

I just want the explanation to the question 'what does windows services basically means?' I want some real time example that i can relate 'windows services' with?
Windows services are background running processes. they dont have UI. Windows services are installed in windows based machines to do some particular tasks on the background like a job. Windows Services has .exe extension but cannot run like a application.
click 'start' in your windows machine, type 'services.msc' and press Enter. This will open windows services installed in your current machine with their active status. If you stop some service, Some relevant application may misbehave. i.e, If any windows application that uses this service for some background job the application would crash.
Antivirus scan, Task scheduler which does some task at specified time are examples of windows services.
In development perspective windows services has
OnStart event (Fires when services start)
OnStop event (Fires when services stop)
timerElapsed event (if you set the interval as 15 seconds, this event fires every 15 seconds)
These services can be created using windows services template in visual studio and installed, uninstalled using 'installutil'
installutil -i servicepath\service.exe (installs service)
installutil -u servicepath\service.exe (uninstalls service)
Windows services can also host wcf services with mex binding. if you have any particular question do let me know. accept if it is useful

Uninstall before installing a windows service

I am reading about how you can create an .exe that will install a windows service to the server.
Say I already have the windows service installed and I want to perform an update. Is there a way for the installer to uninstall (stop the service, delete it, uninstall it) the currently running service and then install the updated version?
Don't be that drastic -- if possible, just stop the service, replace the files you need to, and then (optionally) restart the service.
If you delete the service from the SCM, you lose any post-install configuration done by the user -- custom logon credentials, the settings that dictate what to do when the service crashes, etc.
You shouldn't need to create an exe to do this, the "sc" command can uninstall, update, and install services on Windows for you. See:
Using SC.EXE to Develop Windows NT Services
How to create a Windows service by using Sc.exe
If you still really want to do this by creating your own executable you certainly can, if you can let us know what language you're working in code samples can be provided.

Resources