使用BAT安装 Windows Service
脚本如下:
@echo off
@setlocal enableextensions @cd /d "%~dp0"
set InstallPath=C:\DBoxService\Server set UtilToolPath=C:\Windows\Microsoft.NET\Framework\v2.0.50727
echo Local installation folder - %InstallPath%
IF NOT EXIST "%InstallPath%" ( MKDIR "%InstallPath%" ECHO Folder %InstallPath% created )
IF EXIST "%InstallPath%\DropboxWindowsService.exe" ( %UtilToolPath%\InstallUtil.exe "%InstallPath%\DropboxWindowsService.exe" /u ECHO Unregistered Service: %InstallPath%\DropboxWindowsService.exe )
echo Start to copy files to service folder
copy DropboxWindowsService.exe "%InstallPath%" copy DropboxWindowsService.exe.config "%InstallPath%" copy DropboxCore.dll "%InstallPath%" copy log4net.dll "%InstallPath%"
ECHO Program files copied to %InstallPath%
%UtilToolPath%\InstallUtil.exe "%InstallPath%\DropboxWindowsService.exe" ECHO Registered Service (%InstallPath%\DropboxWindowsService.exe)
net start DropboxWindowsService
ECHO DropBox Windows Service Installed on Server Successfully!
pause
其中出现过错误:
Uninstalling assembly 'C:\DBoxService\Server\DropboxWindowsService.exe'.
Affected parameters are:
logtoconsole =
assemblypath = C:\DBoxService\Server\DropboxWindowsService.exe
logfile = C:\DBoxService\Server\DropboxWindowsService.InstallLog
An exception occurred while trying to find the installers in the C:\DBoxService\Server\DropboxWindowsService.exe assembly.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Aborting installation for C:\DBoxService\Server\DropboxWindowsService.exe.
Installing assembly 'C:\DBoxService\Server\DropboxWindowsService.exe'.
出现这个错误的原因是项目中引用的DLL名称变了,而安装包里面的DLL没有跟着改变,造成了上面的错误。
如果安装时出现“生成此程序集的运行时比当前加载的运行时新”,则可能是服务成员的.net framework 版本比脚本中调用的InstallUtil.exe高
解决办法是调用更高版本的InstallUtil.exe ,例如,黄色的为版本号
C:\WINDOWS\Microsoft.Net\Framework\v4.0.30319\InstallUtil.exe
使用BAT安装 Windows Service的更多相关文章
- 安装Windows Service总是发生异常!
打开VS2010 创建个windows服务应用程序!没有添加删除任何一行代码!然后按照下面的步骤 1. 将这个服务程序切换到设计视图2. 右击设计视图选择“添加安装程序”3. 切换到刚被添加的Proj ...
- 如何通过写bat 安装Windows服务,本人亲测成功
1. 安装的bat文件 @echo on color 2f mode con: cols=80 lines=25 @echo 请按任意键开始安装后台服务... pause cd /d %~dp0 Le ...
- installutil 安装windows service
1:路径:C:\Windows\Microsoft.NET\Framework\v4.0.30319 2:执行指令:C:\Windows\Microsoft.NET\Framework\v4.0.30 ...
- 安装 Windows Service
1.打开 VS 命令行窗口 2. installutil /u service文件路径 (卸载原有服务) 3, installutil /i service 文件路径 (安装服务)
- Windows Service 学习系列(二):C# windows服务:安装、卸载、启动和停止Windows Service几种方式
一.通过InstallUtil.exe安装.卸载.启动.停止Windows Service 方法一 1.以管理员身份运行cmd 2.安装windows服务 切换cd C:\Windows\Micros ...
- Windows Service的安装卸载 和 Service控制(转)
Windows Service的安装卸载 和 Service控制 原文地址:http://www.cnblogs.com/Peter-Zhang/archive/2011/10/15/2212663. ...
- Windows Service的安装卸载 和 Service控制
原文 Windows Service的安装卸载 和 Service控制 本文内容包括如何通过C#代码安装Windows Service(exe文件,并非打包后的安装文件).判断Service是否存在. ...
- 安装windows服务批处理代码
批处理是DOS时代比较常用的方法之一,目前来说也是一种高效的方法,复制代码到文本文件中,保存并修改文件扩展名为“*.bat”. 安装windows服务批处理代码如下: @echo off set fi ...
- .NET开发Windows Service程序 - Topshelf
在实际项目开发过程中,会经常写一些类似定时检查,应用监控的应用.这类应用在windows平台通常都会写成window service程序. 在百度上搜索一下'c#开发windows service', ...
随机推荐
- Elven Postman(BST )
Elven Postman Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- C#调用java类、jar包方法
一.将已经编译后的java中Class文件进行打包:打包命令JAR 如:将某目录下的所有class文件夹全部进行打包处理: 使用的命令:jar cvf test.jar -C com/ . 其中tes ...
- iOS开发——UI进阶篇(十四)modal
一.modal与pushmodal从下面往上盖住原来的控制器,一般上一个控制器和下一个控制器没有什么关联时用modal,比如联系人的加号跳转页面,任何控制器都可以用modal push一般是上下文有关 ...
- 用int类型表示最大公倍数
代码 #include<stdio.h> #include<stdlib.h> #include<limits.h> int main(void) { int m, ...
- OpenCV进阶之路:神经网络识别车牌字符
1. 关于OpenCV进阶之路 前段时间写过一些关于OpenCV基础知识方面的系列文章,主要内容是面向OpenCV初学者,介绍OpenCV中一些常用的函数的接口和调用方法,相关的内容在OpenCV的手 ...
- OpenCV成长之路(5):图像直方图的应用
正如第4篇文章所说的图像直方图在特征提取方面有着很重要的作用,本文将举两个实际工程中非常实用的例子来说明图像直方图的应用. 一.直方图的反向映射. 我们以人脸检测举例,在人脸检测中,我们第一步往往需要 ...
- U盘安装ubuntu server 14.04
U盘安装ubuntu server 14.04 U盘安装ubuntu server 14.04 1.制作启动u盘 2.开始安装 1 将u盘插入主机,重启后从u盘启动 2 选择语言(随便挑,随便选),我 ...
- hdu1536&&hdu3023 SG函数模板及其运用
S-Nim Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status ...
- zabbix之Nginx安装
转载自 http://www.ttlsa.com/nginx/nginx-install-on-linux/ Nginx下载 https://pan.baidu.com/s/1qXT54sO
- PHP检测每一段代码执行时间
<?php // 实例1 /** * @start time */ function proStartTime() { global $startTime; $mtime1 = explode( ...