使用BAT安裝 Windows Service

來源:互聯網
上載者:User

標籤:使用   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沒有跟著改變,造成了上面的錯誤。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.