我用.Net(C#)创建一个Windows服务;创建新的帐户,并指定为“作为服务登录”;用工具InstallUtil.exe安装服务却始终失败,原因是“异常System.ComponentModel.Win32Exception: 帐户名无效或不存在,或者密码对于指定的帐户名无效。”。请问这是为什么?

解决方案 »

  1.   

    请用ADMIN权限试试.如果行,在考虑帐号设置不对..
      

  2.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughcreatingwindowsserviceapplication.asp
      

  3.   

    ProjectInstaller.cs 中有一个 serviceProcessInstaller1 的account 属性.设成localsystem就可以了.
      

  4.   

    把serviceProcessInstaller1 的account设置为User,安装后再在Windows Service中指定你的用户。
      

  5.   

    Account改成LocalSystem的确可以了,感谢"yanlixin4csdn(闫力昕)"。不过问题还是不断,服务无法启动,提示是:“本地计算机上的 xx 服务启动后又停止了。一些服务自动停止,如果它们没有什么可做的,例如‘性能日志和警报’服务”!我是按照微软的例子做的,竟有这么多问题!?
    http://www.microsoft.com/china/technet/security/guidance/secmod29.mspx
      

  6.   

    ProjectInstaller.cs  serviceProcessInstaller1 的account 属性.设成localsystem
      

  7.   

    RemotingConfiguration.Configure(args[0]);
    改为
    System.Runtime.Remoting.RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "RemoteServer1.exe.config");
    其中 RemoteServer1.exe为你服务程序的exe文件名
    试试
      

  8.   

    是不是你的服务里有form啊?如果有的话在服务管理中点右键属性.把允许服务与桌面交与勾上.
      

  9.   

    to LoveCherry:你的意思是服务属性里不设命令行参数,配置文件在代码中指定!还是不行!to yanlixin4csdn:没有Form,我也试过,问题依旧!谢谢各位啦!希望有更好的办法!