Vik*_*dey 304 c# windows-services command-prompt
我想使用Windows命令提示符(而不是Visual Studio命令提示符)安装Windows服务.
我该怎么做呢?
小智 484
导航到.net文件夹中的installutil.exe(例如.net 4,例如C:\ Windows\Microsoft.NET\Framework\v4.0.30319)并使用它来安装您的服务,如下所示:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"
Run Code Online (Sandbox Code Playgroud)
Sid*_*Sid 174
SC Create命令没有错.只是你需要知道正确的args:
SC CREATE "MySVC" binpath= "D:\Me\Services\MySVC\MySVC.exe"
Run Code Online (Sandbox Code Playgroud)
Dha*_*777 82
如果目录的名称有空格c:\program files\abc 123,则必须在路径周围使用双引号.
installutil.exe "c:\program files\abc 123\myservice.exe"
Run Code Online (Sandbox Code Playgroud)

如果您设置如下的bat文件,它会使事情变得更容易,
例如,要安装服务,请创建"myserviceinstaller.bat"和" 以管理员身份运行 "
@echo off
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
installutil.exe "C:\Services\myservice.exe"
if ERRORLEVEL 1 goto error
exit
:error
echo There was a problem
pause
Run Code Online (Sandbox Code Playgroud)
卸载服务,
只需在installutil命令中添加-u即可.
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "C:\Services\myservice.exe"
Run Code Online (Sandbox Code Playgroud)
Bas*_*e33 16
执行以下操作:
c:\windows\microsoft.net\framework\v4.0.30319\installutil.exe [your windows service path to exe]使用管理员权限打开很重要,否则您可能会发现无意义的错误.如果你得到任何,请检查你是否先用管理员权限打开它!
要使用管理员权限打开,请右键单击"命令提示符"并选择"以管理员身份运行".
资料来源:http: //coderamblings.wordpress.com/2012/07/24/how-to-install-a-windows-service-using-the-command-prompt/
小智 8
安装服务: -
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe"
"C:\Services\myservice.exe"
Run Code Online (Sandbox Code Playgroud)
UnInstall服务: -
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" -u "C:\Services\myservice.Service.exe"
Run Code Online (Sandbox Code Playgroud)
创建*.bat你的windows服务旁文件exe文件安装有以下方面:
CLS
ECHO Installing My Windows Service
START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "%~d0%~p0\YourWindowsServiceExeName.exe"
Run Code Online (Sandbox Code Playgroud)
创建*.bat你的windows服务旁文件exe文件卸载有以下方面:
CLS
ECHO Uninstalling My Windows Service
START %windir%\Microsoft.NET\Framework\v4.0.30319\installutil.exe -u "%~d0%~p0\YourWindowsServiceExeName.exe"
Run Code Online (Sandbox Code Playgroud)
以管理员身份运行每个bat文件以安装或卸载您的 Windows 服务。
我必须在这个帖子中再加一点.要安装/卸载64位版本的程序集,应使用64位版本的工具.要安装服务,该命令应为:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe"
"C:\YourFolder\YourService.exe"
Run Code Online (Sandbox Code Playgroud)
并卸载命令应该是:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe" -u
"C:\YourFolder\YourService.exe"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
539727 次 |
| 最近记录: |