0

次のコード(batファイル)でインストールされたWindowsサービスがあります:

@ECHO OFF

REM The following directory is for .NET 4.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX2%

echo Installing IEPPAMS Win Service...
echo ---------------------------------------------------
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil "%~dp0MyApp5.WindowsService.exe"
echo ---------------------------------------------------
pause
echo Done.

これは、Windows Server を実行しているほとんどすべてのコンピューターでうまく機能します。場合によっては、バット ファイルを ANSI または UTF8 として再保存する必要がありますが、その後はほとんどの場合に機能します。

ただし、Windows Server 2012 コンピューターで、 install.but fil を使用すると次の例外が発生しました。

Installing IEPPAMS Win Service...
---------------------------------------------------
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.18010
Copyright (C) Microsoft Corporation.  All rights reserved.


Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:\MyAppService54\MyApp5.WindowsService
.exe assembly's progress.
The file is located at C:\MyAppService54\MyApp5.WindowsService.InstallLog.
Installing assembly 'C:\MyAppService54\MyApp5.WindowsService.exe'.
Affected parameters are:
   logtoconsole =
   assemblypath = C:\MyAppService54\MyApp5.WindowsService.exe
   logfile = C:\MyAppService54\MyApp5.WindowsService.InstallLog
Unable to create an instance of the MyApp5.WindowsService.ProjectInstaller insta
ller type.
System.Reflection.TargetInvocationException: Exception has been thrown by the ta
rget of an invocation.
The inner exception System.NullReferenceException was thrown with the following
error message: Object reference not set to an instance of an object..

An exception occurred during the Install phase.
System.InvalidOperationException: Unable to create an instance of the MyApp5.Win
dowsService.ProjectInstaller installer type.
The inner exception System.Reflection.TargetInvocationException was thrown with
the following error message: Exception has been thrown by the target of an invoc
ation..
The inner exception System.NullReferenceException was thrown with the following
error message: Object reference not set to an instance of an object..

The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\MyAppService54\MyApp5.WindowsService
.exe assembly's progress.
The file is located at C:\MyAppService54\MyApp5.WindowsService.InstallLog.
Rolling back assembly 'C:\MyAppService54\MyApp5.WindowsService.exe'.
Affected parameters are:
   logtoconsole =
   assemblypath = C:\MyAppService54\MyApp5.WindowsService.exe
   logfile = C:\MyAppService54\MyApp5.WindowsService.InstallLog
Unable to create an instance of the MyApp5.WindowsService.ProjectInstaller insta
ller type.
System.Reflection.TargetInvocationException: Exception has been thrown by the ta
rget of an invocation.
The inner exception System.NullReferenceException was thrown with the following
error message: Object reference not set to an instance of an object..
An exception occurred during the Rollback phase of the System.Configuration.Inst
all.AssemblyInstaller installer.
System.InvalidOperationException: Unable to create an instance of the MyApp5.Win
dowsService.ProjectInstaller installer type.
The inner exception System.Reflection.TargetInvocationException was thrown with
the following error message: Exception has been thrown by the target of an invoc
ation..
The inner exception System.NullReferenceException was thrown with the following
error message: Object reference not set to an instance of an object..
An exception occurred during the Rollback phase of the installation. This except
ion will be ignored and the rollback will continue. However, the machine might n
ot fully revert to its initial state after the rollback is complete.

The Rollback phase completed successfully.

The transacted install has completed.
The installation failed, and the rollback has been performed.
---------------------------------------------------
Press any key to continue . . .

NullRef 例外が発生することがわかりますが、これは発生しませんか? 他のすべてのコンピューターでは正常に動作しています。この特定の環境には追加のセキュリティ ルールがあることは知っていますが、これでしょうか?

4

2 に答える 2

0

エクスプローラーですべてのセキュリティ設定を有効にし、再ダウンロードを行うと、機能しました。エクスプローラーがセキュリティに基づいて zip ファイルの内容を変更する方法がわかりません。ブロック/ブロック解除の問題については知っていますが、そうではありませんでした。

于 2013-10-02T06:07:29.200 に答える
0

コマンドプロンプトからこれを試してください:

>sc create "servicenameABC" binPath="path to your service location"

services.msc に移動すると、そこにリストされているサービス (servicenameABC) が見つかります。

于 2015-07-03T07:38:37.373 に答える