zoukankan      html  css  js  c++  java
  • 使用InstallUtil安装WINDOWS服务时,会被360木马防火墙阻止。

    使用InstallUtil安装WINDOWS服务时,会被360木马防火墙阻止。不好跟踪到安装结果。

     //使用.NET的 InstallUtil.exe 来安装服务
                string sInstallUtil = System.Environment.GetEnvironmentVariable("WINDIR") + @"\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe";
                if (!File.Exists(sInstallUtil))
                {
                    MessageBox.Show("InstallUtil 工具不存在。");
                    return;
                }
    
    ProcessStartInfo pStart = new ProcessStartInfo(sInstallUtil);
                    Process pRoc = new Process();
    
                        pStart.Arguments = " " + svrPath;
                        pStart.UseShellExecute = false;
                        pStart.CreateNoWindow = false;
    
                        pRoc.StartInfo = pStart;
                        pRoc.Start();
                        pRoc.WaitForExit();

    换成AssemblyInstaller,

    //被360木马防火墙阻止时,会引发异常。
                        IDictionary mySavedState = new Hashtable();
                        AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
                        myAssemblyInstaller.UseNewContext = true;
                        myAssemblyInstaller.Path = svrPath;
                        myAssemblyInstaller.Install(mySavedState);
                        myAssemblyInstaller.Commit(mySavedState);
                        myAssemblyInstaller.Dispose();

    exp.GetType().Name == "Win32Exception"

  • 相关阅读:
    javaweb基础笔记(2)
    javaweb基础笔记(1)
    java基础笔记(11)
    java基础笔记(10)
    java基础笔记(9)
    洛谷 P2648 赚钱
    AcWing 走廊泼水节 题解
    对于有向图多个点到一个点的求法
    分层图的四倍经验
    洛谷 P4822 [BJWC2012]冻结
  • 原文地址:https://www.cnblogs.com/runliuv/p/2491347.html
Copyright © 2011-2022 走看看