2012-05-02 79 views
1

我有C#编写的,我需要安装和调试的自定义Windows服务。当我使用installutil与Windows服务安装,然后立即卸载定制窗口服务

installutil "[path].exe" 

在命令行,然后尝试与搜索服务,它不会出现在任何地方安装的服务列表。纵观安装日志文件,我看到:

Installing assembly 'myservice'. 
Affected parameters are: 
    logtoconsole =  
    assemblypath = mypath 
    logfile = mylogfile 
Installing service MyService 
Service MyService has been successfully installed. 
Creating EventLog source MyService in log Application... 
Committing assembly 'myservice'. 
Affected parameters are: 
    logtoconsole = 
    assemblypath = myservice 
    logfile = pathtoinstalllog 
Uninstalling assembly myservice 
Affected parameters are: 
    logtoconsole = 
    assemblypath = myservice 
    logfile = pathtoinstalllog 
Removing EventLog source myservice. 
Service myservice is being removed from the system... 
Service myservice was successfully removed from the system. 
Uninstalling assembly myservice'. 
Affected parameters are:  
    logtoconsole = 
    assemblypath = myservice 
    logfile = pathtoinstalllog 
Removing EventLog source myservice. 
Service myservice is being removed from the system... 
Service myservice was successfully removed from the system. 

(名称路径,为MyService,pathtoinstalllog等到位公司具体情况)

无论如何,从日志文件时,它看起来好像服务正在安装,然后立即卸载......

如果需要更多的代码或信息,让我知道,在此先感谢。

+0

Should't您可以指定标志'-i'把这件事告诉'install'? – Suhas

+0

你在日志文件中得到任何错误?这是来自installlog文件的完整日志。同时检查我们的代码不会导致卸载 –

+0

哦,我认为这是默认值..无论哪种方式,它并没有改变任何东西:\ –

回答

2

来概括根据我们讨论...

  • 使用 'InstallUtil full-path' 为您服务的主要输出(斌/调试/ assembly.exe)。通常,如果有一个错误InstallUtil“执行回滚”(所以看为错误) - 它看起来像它这样做,但你的日志不说 - 所以我猜你“的MyService”是错误的路径(也挑右InstallUtil版本,.NET框架和32/64)...

  • 安全/帐户问题 - run InstallUtil elevated('以管理员身份运行',命令提示符等) - (如果需要其他调试,请尝试指定不同的用户/类型为您的服务帐户,检查您的安装程序类的详细信息,RunInstaller属性等)。

希望这有助于

+0

最后一个问题 - 我使用SYSTEM用户进行服务。这是好的,如果不是,我该如何改变它? 编辑:没关系,我在安装程序代码中找到它。第一个问题仍然存在,虽然大声笑 –

+0

是的,在安装程序中 - '我不会使用'系统'帐户(我猜你正在谈论LocalSystem)。 '首选项总是与'最小特权'一起进行,通常是'ServiceAccount.LocalService',如果它完成了工作'。通过'System.ServiceProcess.ServiceAccount'的描述,它对他们每个人都说了一点。理想情况下,如果可以的话,为了适当的安全设置(并且能够进行微观管理,稍后控制),设置一个单独的用户(对于服务或类别服务的“类别”)并且给它“足够的”特权'。但这更多的是'安全':) :) – NSGaga

+0

http://stackoverflow.com/questions/510170/the-difference-between-the-local-system-account-and-the-network-service-acco - 或这个链接 – NSGaga