码迷,mamicode.com
首页 > Windows程序 > 详细

使用BAT安装 Windows Service

时间:2014-07-16 21:03:47      阅读:326      评论:0      收藏:0      [点我收藏+]

标签:使用   os   art   for   io   cti   

脚本如下:

@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没有跟着改变,造成了上面的错误。

 

使用BAT安装 Windows Service,布布扣,bubuko.com

使用BAT安装 Windows Service

标签:使用   os   art   for   io   cti   

原文地址:http://www.cnblogs.com/tylertang/p/3836439.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!