当前位置:   article > 正文

使用Windows命令提示符安装Windows服务吗?_用命令提示符安装服务

用命令提示符安装服务

本文翻译自:Install a Windows service using a Windows command prompt?

I want to install a Windows service using a Windows command prompt (not the Visual Studio command prompt). 我想使用Windows命令提示符(而不是Visual Studio命令提示符)安装Windows服务。

How do I do this? 我该怎么做呢?


#1楼

参考:https://stackoom.com/question/YG3H/使用Windows命令提示符安装Windows服务吗


#2楼

Perform the following: 执行以下操作:

  1. Start up the command prompt (CMD) with administrator rights. 以管理员权限启动命令提示符(CMD)。
  2. Type c:\\windows\\microsoft.net\\framework\\v4.0.30319\\installutil.exe [your windows service path to exe] 键入c:\\windows\\microsoft.net\\framework\\v4.0.30319\\installutil.exe [your windows service path to exe]
  3. Press return and that's that! 回车键 ,就是这样!

It's important to open with administrator rights otherwise you may find errors that come up that don't make sense. 以管理员权限打开很重要,否则您可能会发现没有道理的错误。 If you get any, check you've opened it with admin rights first! 如果有,请先检查您是否已使用管理员权限打开它!

To open with admin rights , right click 'Command Prompt' and select 'Run as administrator'. 要以管理员权限打开 ,请右键单击“命令提示符”,然后选择“以管理员身份运行”。

Source: http://coderamblings.wordpress.com/2012/07/24/how-to-install-a-windows-service-using-the-command-prompt/ 来源: http : //coderamblings.wordpress.com/2012/07/24/how-to-install-a-windows-service-using-the-command-prompt/


#3楼

If the directory's name has a space like c:\\program files\\abc 123 , then you must use double quotes around the path. 如果目录名称的空格类似c:\\program files\\abc 123 ,则必须在路径周围使用双引号。

installutil.exe "c:\program files\abc 123\myservice.exe"

从命令提示符安装Windows服务

It makes things much easier if you set up a bat file like following, 如果您设置bat文件(例如,

eg To install a service, create a "myserviceinstaller.bat" and " Run as Administrator " 例如,要安装服务,请创建“ myserviceinstaller.bat”和“ 以管理员身份运行

  1. @echo off
  2. cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
  3. installutil.exe "C:\Services\myservice.exe"
  4. if ERRORLEVEL 1 goto error
  5. exit
  6. :error
  7. echo There was a problem
  8. pause

to uninstall service, 卸载服务,

Just add a -u to the installutil command. 只需在installutil命令中添加-u即可。

  1. cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
  2. C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "C:\Services\myservice.exe"

#4楼

when your assembly version and your Visual studio project Biuld setting on dot net 2 or 4 install with same version. 当您的程序集版本和Visual Studio项目在点网2或4上的Biuld设置安装为相同版本时。

install service with installutil that same version 使用相同版本的installutil安装服务

if build in dot net 4 如果内置于点网4

Type c:\\windows\\microsoft.net\\framework\\v4.0.30319\\installutil.exe 键入c:\\windows\\microsoft.net\\framework\\v4.0.30319\\installutil.exe

if build in dot net 2 如果内置点网2

Type c:\\windows\\microsoft.net\\framework\\v2.0.11319\\installutil.exe 键入c:\\windows\\microsoft.net\\framework\\v2.0.11319\\installutil.exe


#5楼

  1. start up the command prompt (CMD) with administrator rights. 以管理员权限启动命令提示符(CMD)。
  2. Type c:\\windows\\microsoft.net\\framework\\v4.0.30319\\installutil.exe [your windows service path to exe] 键入c:\\ windows \\ microsoft.net \\ framework \\ v4.0.30319 \\ installutil.exe [您的exe的Windows服务路径]
  3. Press return 按回车

#6楼

  1. Run Windows Command Prompt as Administrator 管理员身份运行Windows命令提示符
  2. paste this code: cd C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\ to go to folder 粘贴此代码: cd C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\转到文件夹
  3. edit and run this too: installutil C:\\ProjectFolder\\bin\\Debug\\MyProject.exe 也编辑并运行: installutil C:\\ProjectFolder\\bin\\Debug\\MyProject.exe

Note: To uninstall: installutil /u C:\\ProjectFolder\\bin\\Debug\\MyProject.exe 注意:要卸载: installutil /u C:\\ProjectFolder\\bin\\Debug\\MyProject.exe

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/981432
推荐阅读
相关标签
  

闽ICP备14008679号