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"

  • 相关阅读:
    MVC1
    Linux中的软连接与硬连接
    python之multiprocessing(二):multiprocessing.Pool
    python之multiprocessing(一)
    python之paramiko(一)
    python_Exception之:TypeError: 'int' object is not iterable
    python之socket(一)
    python之pymysql(一)
    生成树协议--STP
    路由协议--RIP
  • 原文地址:https://www.cnblogs.com/runliuv/p/2491347.html
Copyright © 2011-2022 走看看