代码之家  ›  专栏  ›  技术社区  ›  rodnower

.NET ServiceInstaller卸载服务的时间过长

  •  0
  • rodnower  · 技术社区  · 16 年前


    当我安装这些服务时,这不会占用太多时间,但当我使用以下代码卸载时,每个服务的过程只需几秒钟(我们有许多服务):

    ServiceInstaller si = new ServiceInstaler();
    string path = string.Format("/assemblypath={0}", strServiceExecutablePath);
    string[] cmdline = { path };
    
    InstallContext context = new InstallContext(string.Empty, cmdline);
    si.Context = context;
    si.ServiceName = strServiceName;
    si.Uninstall(null);
    

    有人知道为什么吗?

    这里我想问一些相关的问题。

    InstallUtill /u exePath
    

    以及:

    sc delete serviceName
    

    为什么当我从CurrentControlSet\services中删除注册表中的一些记录时,我仍然可以在services.msc中看到该服务,但是:

    <Failed to read description. Error code:2
    

    描述中?
    我需要从哪里手动删除服务才能完全删除它?
    谢谢你的邀请。

    1 回复  |  直到 16 年前
        1
  •  0
  •   Ando SylviA    16 年前

    InstallUtil /u exePath 将通过调用安装程序的卸载程序部分来卸载应用程序。

    sc delete serviceName

    关于你的 Failed to read description. Error code:2 看到这个了吗 post sfc /scannow 并检查日志。