2013-10-01 96 views
0

我有一個安裝了下面的代碼(bat文件)Windows服務:在特定計算機上安裝Windows Service失敗?

@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幾乎所有計算機的偉大工程。有時bat文件將不得不重新保存爲ANSI或UTF8,但在此之後,它將在大多數情況下工作。

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例外,但我不明白這一點:

使用install.but FIL時候我已經拼命地跑不過在到Windows Server 2012的計算機在那裏我得到下面的異常?它在所有其他計算機上工作正常。我知道這個特定的環境有一些額外的安全規則,可能是這樣嗎?

+0

它很可能是由於「額外的安全規則」。嘗試使用進程監視器來查看是否存在失敗的基礎文件系統操作。 –

回答

0

通過啓用資源管理器中的所有安全設置並重新下載它的工作。我不知道如何基於安全性的資源管理器將能夠更改壓縮文件的內容。我知道阻擋/解鎖問題,但事實並非如此。

0

在命令PROMT試試這個:

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

現在去SERVICES.MSC你可以找到找到你的服務(servicenameABC)列出, 希望它有助於..