如何在没有安装Visual Studio的机器上安装windows服务?

时间:2022-02-24 06:58:25

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't having Visual Studio installed (assume that .Net version 2.X is installed.)

安装windows服务的唯一方法是使用“Visual Studio 2008命令提示符”,即在没有安装Visual Studio的机器上安装windows服务(假设。net version 2)。X安装。)

9 个解决方案

#1


42  

you can do it with installUtil which resides in the .net framework folder (on my machine it's C:\Windows\Microsoft.NET\Framework\v2.0.50727).

你可以与installUtil驻留在。net框架文件夹(在我的机器上是C:\Windows\ Microsoft.NET \ framework \ v2.0.50727)。

#2


7  

You can install Windows Services as an MSI. Create the MSI as a normal Project attached to your Service Project.

您可以将Windows服务安装为MSI。创建MSI作为附加到服务项目的正常项目。

In your Service Project Create an Installer Class and add the components serviceInstaller and serviceProcessInstaller and configure as required. Add the Project Output from the Service Project to the MSI Project, Set the Custom Actions of the MSI Project for Install, Commit, Rollback and Uninstall to the Output of the Service Project.

在服务项目中,创建一个安装程序类,并添加组件serviceInstaller和serviceProcessInstaller,并根据需要进行配置。将服务项目的项目输出添加到MSI项目中,将MSI项目的自定义操作设置为安装、提交、回滚和卸载到服务项目的输出中。

Alter the MSI Project in any other way as desired, build the MSI, then you will be able to install your Service to any Windows machine without VS.NET or by using the InstallUtil utility application. The MSI will also handle the Uninstall etc.

以任何其他方式修改MSI项目,构建MSI,然后您将能够在没有VS.NET或使用InstallUtil实用程序的情况下将服务安装到任何Windows机器上。MSI也将处理卸载等。

There are properties of the serviceProcessInstaller component which you can set for the Account to run the Service under, the serviceInstaller contains properties which can be set such as the Service Name. You will have to set the ServiceName and its Parent, MSDN will provide good information on how to use both of these components.

serviceProcessInstaller组件有一些属性,您可以将其设置为帐户运行服务,serviceInstaller包含可以设置的属性,如服务名称。您将必须设置ServiceName和它的父类,MSDN将提供如何使用这两个组件的良好信息。

Hope this helps.

希望这个有帮助。

Cheers.

欢呼。

#3


6  

Relevant MSDN page: http://msdn.microsoft.com/en-us/library/sd8zc8ha%28VS.80%29.aspx

相关的MSDN页面:http://msdn.microsoft.com/en-us/library/sd8zc8ha%28VS.80%29.aspx

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil.exe yourproject.exe

You don't need to have Visual Studio installed for this to work.

您不需要安装Visual Studio来工作。

#4


3  

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.

是的,installutil。exe工作得很好,但是我已经厌倦了必须记住启动Visual Studio 2008命令提示符才能使用它。我总是打开一个普通的控制台,结果发现安装程序。exe位置不是路径的一部分。

Fortunately, the installutil.exe is a wrapper around a set of reflection calls. From MSDN,

幸运的是,installutil。exe是围绕一组反射调用的包装器。从MSDN,

Installutil.exe uses reflection to inspect the specified assembly and find all Installer types with the RunInstallerAttribute set to true. The tool then executes either the Install Method or the Uninstall Method on each instance of the Installer type.

Installutil。exe使用反射检查指定的程序集,并找到与RunInstallerAttribute设置为true的所有安装程序类型。然后,该工具在安装程序类型的每个实例上执行安装方法或卸载方法。

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.

这意味着可以向Windows服务添加代码,让它自己安装和卸载。通过这样做,我不再需要installutil。exe或Visual Studio 2008命令提示符来运行它。

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.

我在这里提供了一步一步的指导。安装选项安装Windows服务并启动它。相反,-uninstall选项会停止服务并卸载它。

#5


2  

Open a command prompt (cmd) and type

打开命令提示符(cmd)并输入

help sc

帮助sc

and

sc create

sc创建

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.

此外installutil。你可能正在谈论的exe实际上只是在。net框架目录中。VS的命令提示符设置好路径,但您可以启动它(我)C:\Windows\ Microsoft.NET \ Framework \ v2.0.50727刚刚好。

#6


2  

You don't need the Visual Studio 2008 Command Prompt. You need the InstallUtil.exe program which can be found in

您不需要Visual Studio 2008命令提示符。你需要InstallUtil。可以在exe程序中找到

C:\Windows\Microsoft.NET\Framework\v2.0.50727

C:\Windows\ Microsoft.NET \ Framework \ v2.0.50727

On x64 machines there's also a 64-bit version in

在x64计算机上也有64位版本

C:\Windows\Microsoft.NET\Framework64\v2.0.50727

C:\Windows\ Microsoft.NET \ Framework64 \ v2.0.50727

These directories are obviously only available when .NET is installed.

这些目录显然只有在. net安装时才可用。

#7


2  

All that's doing is putting the .Net framework tools onto the PATH; you can go still use: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe by specifying the full path on a normal command prompt (obviously adjust for your framework / CPU architecture)

所做的就是把。net框架工具放到路径上;你仍然可以使用:C:\WINDOWS\ Microsoft.NET \ Framework \ v2.0.50727 \ InstallUtil。通过在普通命令提示符上指定完整路径(显然是根据框架/ CPU体系结构进行调整)

#8


1  

I guess that you're looking for the "installutil.exe" program, which one uses to install .NET Windows Services. You can find it in %windir%\Microsoft.NET\Framework\v2.0.50727

我猜你在找“installutil”。exe程序,用于安装。net Windows服务。您可以在%windir%\Microsoft.NET\Framework\v2.0.50727中找到它。

#9


1  

With visual studio command prompt:

使用visual studio命令提示符:

installutil /i fullfilepathtoservice.exe

Without visual studio command prompt:

没有visual studio命令提示符:

C:\WINNT\Microsoft.NET\Framework\v1.1.4322 installutil /i fullfilepathtoservice.exe

HTH.

HTH。

#1


42  

you can do it with installUtil which resides in the .net framework folder (on my machine it's C:\Windows\Microsoft.NET\Framework\v2.0.50727).

你可以与installUtil驻留在。net框架文件夹(在我的机器上是C:\Windows\ Microsoft.NET \ framework \ v2.0.50727)。

#2


7  

You can install Windows Services as an MSI. Create the MSI as a normal Project attached to your Service Project.

您可以将Windows服务安装为MSI。创建MSI作为附加到服务项目的正常项目。

In your Service Project Create an Installer Class and add the components serviceInstaller and serviceProcessInstaller and configure as required. Add the Project Output from the Service Project to the MSI Project, Set the Custom Actions of the MSI Project for Install, Commit, Rollback and Uninstall to the Output of the Service Project.

在服务项目中,创建一个安装程序类,并添加组件serviceInstaller和serviceProcessInstaller,并根据需要进行配置。将服务项目的项目输出添加到MSI项目中,将MSI项目的自定义操作设置为安装、提交、回滚和卸载到服务项目的输出中。

Alter the MSI Project in any other way as desired, build the MSI, then you will be able to install your Service to any Windows machine without VS.NET or by using the InstallUtil utility application. The MSI will also handle the Uninstall etc.

以任何其他方式修改MSI项目,构建MSI,然后您将能够在没有VS.NET或使用InstallUtil实用程序的情况下将服务安装到任何Windows机器上。MSI也将处理卸载等。

There are properties of the serviceProcessInstaller component which you can set for the Account to run the Service under, the serviceInstaller contains properties which can be set such as the Service Name. You will have to set the ServiceName and its Parent, MSDN will provide good information on how to use both of these components.

serviceProcessInstaller组件有一些属性,您可以将其设置为帐户运行服务,serviceInstaller包含可以设置的属性,如服务名称。您将必须设置ServiceName和它的父类,MSDN将提供如何使用这两个组件的良好信息。

Hope this helps.

希望这个有帮助。

Cheers.

欢呼。

#3


6  

Relevant MSDN page: http://msdn.microsoft.com/en-us/library/sd8zc8ha%28VS.80%29.aspx

相关的MSDN页面:http://msdn.microsoft.com/en-us/library/sd8zc8ha%28VS.80%29.aspx

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil.exe yourproject.exe

You don't need to have Visual Studio installed for this to work.

您不需要安装Visual Studio来工作。

#4


3  

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.

是的,installutil。exe工作得很好,但是我已经厌倦了必须记住启动Visual Studio 2008命令提示符才能使用它。我总是打开一个普通的控制台,结果发现安装程序。exe位置不是路径的一部分。

Fortunately, the installutil.exe is a wrapper around a set of reflection calls. From MSDN,

幸运的是,installutil。exe是围绕一组反射调用的包装器。从MSDN,

Installutil.exe uses reflection to inspect the specified assembly and find all Installer types with the RunInstallerAttribute set to true. The tool then executes either the Install Method or the Uninstall Method on each instance of the Installer type.

Installutil。exe使用反射检查指定的程序集,并找到与RunInstallerAttribute设置为true的所有安装程序类型。然后,该工具在安装程序类型的每个实例上执行安装方法或卸载方法。

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.

这意味着可以向Windows服务添加代码,让它自己安装和卸载。通过这样做,我不再需要installutil。exe或Visual Studio 2008命令提示符来运行它。

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.

我在这里提供了一步一步的指导。安装选项安装Windows服务并启动它。相反,-uninstall选项会停止服务并卸载它。

#5


2  

Open a command prompt (cmd) and type

打开命令提示符(cmd)并输入

help sc

帮助sc

and

sc create

sc创建

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.

此外installutil。你可能正在谈论的exe实际上只是在。net框架目录中。VS的命令提示符设置好路径,但您可以启动它(我)C:\Windows\ Microsoft.NET \ Framework \ v2.0.50727刚刚好。

#6


2  

You don't need the Visual Studio 2008 Command Prompt. You need the InstallUtil.exe program which can be found in

您不需要Visual Studio 2008命令提示符。你需要InstallUtil。可以在exe程序中找到

C:\Windows\Microsoft.NET\Framework\v2.0.50727

C:\Windows\ Microsoft.NET \ Framework \ v2.0.50727

On x64 machines there's also a 64-bit version in

在x64计算机上也有64位版本

C:\Windows\Microsoft.NET\Framework64\v2.0.50727

C:\Windows\ Microsoft.NET \ Framework64 \ v2.0.50727

These directories are obviously only available when .NET is installed.

这些目录显然只有在. net安装时才可用。

#7


2  

All that's doing is putting the .Net framework tools onto the PATH; you can go still use: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe by specifying the full path on a normal command prompt (obviously adjust for your framework / CPU architecture)

所做的就是把。net框架工具放到路径上;你仍然可以使用:C:\WINDOWS\ Microsoft.NET \ Framework \ v2.0.50727 \ InstallUtil。通过在普通命令提示符上指定完整路径(显然是根据框架/ CPU体系结构进行调整)

#8


1  

I guess that you're looking for the "installutil.exe" program, which one uses to install .NET Windows Services. You can find it in %windir%\Microsoft.NET\Framework\v2.0.50727

我猜你在找“installutil”。exe程序,用于安装。net Windows服务。您可以在%windir%\Microsoft.NET\Framework\v2.0.50727中找到它。

#9


1  

With visual studio command prompt:

使用visual studio命令提示符:

installutil /i fullfilepathtoservice.exe

Without visual studio command prompt:

没有visual studio命令提示符:

C:\WINNT\Microsoft.NET\Framework\v1.1.4322 installutil /i fullfilepathtoservice.exe

HTH.

HTH。