zoukankan      html  css  js  c++  java
  • 使用BAT安装 Windows Service

    脚本如下:

    @echo off

    @setlocal enableextensions @cd /d "%~dp0"

    set InstallPath=C:DBoxServiceServer set UtilToolPath=C:WindowsMicrosoft.NETFrameworkv2.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:DBoxServiceServerDropboxWindowsService.exe'.
    Affected parameters are:
       logtoconsole =
       assemblypath = C:DBoxServiceServerDropboxWindowsService.exe
       logfile = C:DBoxServiceServerDropboxWindowsService.InstallLog
    An exception occurred while trying to find the installers in the C:DBoxServiceServerDropboxWindowsService.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:DBoxServiceServerDropboxWindowsService.exe.
    Installing assembly 'C:DBoxServiceServerDropboxWindowsService.exe'.

    出现这个错误的原因是项目中引用的DLL名称变了,而安装包里面的DLL没有跟着改变,造成了上面的错误。

    如果安装时出现“生成此程序集的运行时比当前加载的运行时新”,则可能是服务成员的.net framework 版本比脚本中调用的InstallUtil.exe高

    解决办法是调用更高版本的InstallUtil.exe ,例如,黄色的为版本号
    C:WINDOWSMicrosoft.NetFrameworkv4.0.30319InstallUtil.exe

  • 相关阅读:
    GAMES101作业1:旋转与投影
    ant design vue关于input组件设置只读
    使用事件代理解决v-html点击事件无效
    js替换字符串中的空格,换行符 或 替换成<br>
    vue中ref的使用(this.$refs获取为undefined)
    轮询锁在使用时遇到的问题与解决方案!
    死锁终结者:顺序锁和轮询锁!
    死锁的 4 种排查工具 !
    图解:为什么非公平锁的性能更高?
    抽奖动画
  • 原文地址:https://www.cnblogs.com/tylertang/p/3836439.html
Copyright © 2011-2022 走看看