The only way to install windows-service I know is using \"Visual Studio 2008 Command Prompt\", Is there a way to install windows-service on a machine which isn\
step 1> Install .net framework (I am using .net 4.0 but you can use as your requirement)
step 2> Go to run + cmd
then click ok or directly go to your window command prompt (not visual studio command prompt )
step 3> type these lines
> cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
> E:\test\test\bin\Debug\test.exe
E:\test\test\bin\Debug\
is the path where my window service setup is saved
C:\Windows\Microsoft.NET\Framework\v4.0.30319\
is path where InstallUtil.exe exist.
In both InstallUtil.exe exist. and path must give a space. Otherwise, it raises an error.
Step 4> Enjoy..your service is installed...now you can check it from control panel > administrative tool >Services.
Yep, installutil.exe works nicely, but I got tired of having to remember to start the Visual Studio 2008 Command Prompt in order to use it. Invariably, I'd open an ordinary console only to realize that the installutil.exe
location was not part of the path.
Fortunately, the installutil.exe
is a wrapper around a set of reflection calls. From MSDN,
Installutil.exe
uses reflection to inspect the specified assembly and find allInstaller
types with theRunInstallerAttribute
set to true. The tool then executes either the Install Method or the Uninstall Method on each instance of theInstaller
type.
What this means is that it is possible to add code to the Windows service to have it install and uninstall itself. By doing so, I no longer require installutil.exe
or the Visual Studio 2008 Command Prompt to run it.
I have provided a step-by-step guide for how to do this here. The -install
option installs the Windows service and starts it. Conversely, the -uninstall
option stops the service and uninstalls it.
Open a command prompt (cmd) and type
help sc
and
sc create
In additon the installutil.exe you're probably talking about is really just in the .Net Framework directory. The command prompt of VS just sets up a nice path, but you can launch it from (my path) C:\Windows\Microsoft.NET\Framework\v2.0.50727 just fine.
Run CMD as admin
Go to
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>
RUN the following:
InstallUtil C:\Dev\Codebase..\Main\Source....\bin\Debug\.exe
You don't need the Visual Studio 2008 Command Prompt. You need the InstallUtil.exe program which can be found in
C:\Windows\Microsoft.NET\Framework\v2.0.50727
On x64 machines there's also a 64-bit version in
C:\Windows\Microsoft.NET\Framework64\v2.0.50727
These directories are obviously only available when .NET is installed.