static void Main(string[] args)
        {
            Publish p = new Publish();

            p.GacInstall(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/lib/OSAE.API.dll");
            p.GacInstall(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/lib/MySql.Data.dll");
        }
Example #2
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    return;
                }

                Publish p = new Publish();

                if (args[0] == "/install")
                {
                    p.GacInstall("EntitySpaces.Common.dll");
                    p.GacInstall("EntitySpaces.MetadataEngine.dll");
                    p.GacInstall("EntitySpaces2019.AddIn.dll");
                    p.GacInstall("EntitySpaces.AddIn.TemplateUI.dll");
                    p.GacInstall("EntitySpaces.CodeGenerator.dll");
                }
                else if (args[0] == "/remove")
                {
                    p.GacRemove("EntitySpaces.MetadataEngine.dll");
                    p.GacRemove("EntitySpaces2019.AddIn.dll");
                    p.GacRemove("EntitySpaces.AddIn.TemplateUI.dll");
                    p.GacRemove("EntitySpaces.CodeGenerator.dll");
                    p.GacRemove("EntitySpaces.TemplateUI.dll");
                    p.GacRemove("EntitySpaces.MSDASC.dll");
                    p.GacRemove("EntitySpaces.Common.dll");
                }
            }
            catch { }
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string path = textBox1.Text;

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (!Directory.Exists(path))
            {
                MessageBox.Show("No such directory!");
                return;
            }

            textBox2.Clear();

            var files     = Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories);
            var publisher = new Publish();

            foreach (var file in files)
            {
                try
                {
                    publisher.GacInstall(file);
                    log("PROCESSED: " + Path.GetFileName(file));
                    Application.DoEvents();
                }
                catch (Exception ex)
                {
                    log("ERROR: " + ex.Message);
                }
            }
        }
Example #4
0
        /// <summary>
        ///     Inject our assembly to the Global Assembly Cache so all scripts have access to it
        /// </summary>
        private void InjectToGAC()
        {
            //Allows other scripts to access us
            var pub = new Publish();

            pub.GacInstall(typeof(DeveloperConsole).Assembly.Location);
        }
Example #5
0
        // ACT에 어셈블리 등록
        private static void RegisterActAssemblies()
        {
            var pub = new Publish();

            var pin = ActGlobals.oFormActMain.ActPlugins.FirstOrDefault(x => x.pluginFile.Name.Equals("ACT.DFAssist.dll"));

            Settings.PluginPath = pin?.pluginFile.DirectoryName;

            if (Settings.PluginPath == null)
            {
                return;
            }

            foreach (var d in Dependencies)
            {
                var dll = Path.Combine(Settings.PluginPath, d);
                try
                {
                    pub.GacInstall(dll);
                }
                catch (Exception ex)
                {
                    ActGlobals.oFormActMain.WriteExceptionLog(ex, "ACT.DFAssist: cannot registry dependency dll");
                }
            }
        }
Example #6
0
 public static void GacInstall(string AssemblyPath)
 {
     if (!System.IO.File.Exists(AssemblyPath))
     {
         return;
     }
     publish.GacInstall(AssemblyPath);
 }
        private static void InstallAssembly(Kernel kernel)
        {
            Publish publish = new Publish();
            string  file    = kernel.CommandLine["install"];

            //Console.WriteLine(".."+file+"..");
            publish.GacInstall(file);
        }
Example #8
0
        static void Main(string[] args)
        {
            Publish p = new Publish();

            p.GacInstall(@"C:\Users\naynish\Desktop\Dummy Projects\GacInstall\CustomCalcLibrary.dll");
            Console.WriteLine("Installed to Global Assembly Cache");
            Console.ReadLine();
        }
Example #9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates all files that require an update.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateFiles()
        {
            bool fAskedUserToExit = false;             // will be set to true as soon as we have asked user

            using (ProgressDialog dlg = new ProgressDialog())
            {
                dlg.ProgressBar.Maximum = m_FilesToUpdate.Length;
                dlg.Show();
                for (int i = 0; i < m_FilesToUpdate.Length && !dlg.ShouldCancel; i++)
                {
                    UpdateFile file = m_FilesToUpdate[i];
                    Trace.WriteLine(DateTime.Now + ": Installing " + file.Name);
                    dlg.InstallText = "Installing " + file.Name;

                    if (file.ExitVs && !fAskedUserToExit)
                    {
                        fAskedUserToExit = true;
                        CloseVs();
                    }

                    try
                    {
                        string extension = Path.GetExtension(file.Name).ToLower();
                        if (extension == ".msi" || extension == ".vsi" || extension == ".vsix")
                        {
                            // Install this file
                            Process process = new Process();
                            process.StartInfo.FileName       = Path.Combine(m_UpdatePath, file.Name);
                            process.StartInfo.CreateNoWindow = true;
                            process.StartInfo.Arguments      = "/quiet";
                            process.Start();
                            process.WaitForExit();
                            Trace.WriteLine(DateTime.Now + ": Exit code: " + process.ExitCode);
                        }
                        else if (extension == ".dll")
                        {
                            // Install in the GAC
                            string  fileName = Path.Combine(m_UpdatePath, file.Name);
                            Publish publish  = new Publish();
                            publish.GacInstall(fileName);
                            Trace.WriteLine(DateTime.Now + ": Installed in GAC");
                        }
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(DateTime.Now + ": Got exception installing " +
                                        file.Name + ": " + e.Message);
                        // remove from list of updated files so that we try again
                        m_FileHash.Remove(file.Name);
                    }
                    dlg.ProgressBar.Increment(1);
                }

                RestartVisualStudio(dlg);
                dlg.Close();
            }
        }
Example #10
0
        // Methods
        static void Main(string[] args)
        {
            string pattern = "";

            if (args.Length > 0)
            {
                pattern = args[0];
            }

            bool flag = true;

            if (args.Length == 2)
            {
                flag = args[1] == "i";
            }
            var  publish = new Publish();
            bool error   = false;

            foreach (var file in GetFiles())
            {
                try {
                    if (Regex.IsMatch(Path.GetFileNameWithoutExtension(file) + "", pattern))
                    {
                        if (flag)
                        {
                            publish.GacInstall(file);
                            Console.WriteLine("Installed: " + file);
                        }
                        else
                        {
                            var windowsPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
                            var path        = windowsPath + @"\Microsoft.NET\assembly\GAC_MSIL\" + Path.GetFileNameWithoutExtension(file);
                            if (Directory.Exists(path))
                            {
                                Directory.Delete(path, true);
                                Console.WriteLine("Uninstalled: " + Path.GetFileNameWithoutExtension(file));
                            }
                            else
                            {
                                Console.WriteLine("Already uninstalled: " + Path.GetFileNameWithoutExtension(file));
                            }
                        }
                    }
                }
                catch (Exception exception) {
                    error = true;
                    var foregroundColor = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(new Exception("ERROR in " + Path.GetFileNameWithoutExtension(file), exception));
                    Console.ForegroundColor = foregroundColor;
                }
            }
            if (error)
            {
                Console.ReadKey();
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            //System.Console.Out.WriteLine("arguments: "+args.Length);

            try
            {
                if (args.Length == 2)
                {
                    Publish p = new Publish();
                    if (args[0] == "install")
                    {
                        System.Console.Out.WriteLine("Registering {0} into GAC", args[1]);
                        p.GacInstall(args[1]);
                    }
                    else if (args[0] == "remove")
                    {
                        System.Console.Out.WriteLine("Removing {0} from GAC", args[1]);
                        p.GacRemove(args[1]);
                    }
                    else if (args[0] == "installasm")
                    {
                        System.Console.Out.WriteLine("Registering Assembly {0}", args[1]);
                        RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();
                        Assembly             ass    = Assembly.LoadFrom(args[1]);
                        regsrv.RegisterAssembly(ass,
                                                System.Runtime.InteropServices.AssemblyRegistrationFlags.SetCodeBase);
                        //p.RegisterAssembly(args[1]);
                    }
                    else if (args[0] == "removeasm")
                    {
                        System.Console.Out.WriteLine("Removing Assembly {0}", args[1]);
                        RegistrationServices regsrv = new System.Runtime.InteropServices.RegistrationServices();
                        Assembly             ass    = Assembly.LoadFrom(args[1]);
                        regsrv.UnregisterAssembly(ass);
                        //p.UnRegisterAssembly(args[1]);
                    }
                    else
                    {
                        displayUsage();
                    }
                }
                else
                {
                    displayUsage();
                }
            }
            catch (Exception E) {
                String s = "Error " + E.Source + " while " + args[0] + " " + args[1] + ": " + E.Message;
                s = DateTime.Now.ToString() + " " + s;
                System.Console.Out.WriteLine(s);
            }
        }
Example #12
0
 public override void Install(IDictionary stateSaver)
 {
     try
     {
         Publish publish = new Publish();
         publish.GacInstall("WhereMyImplant.dll");
         base.Install(stateSaver);
         RegistrationServices registrationServices = new RegistrationServices();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Example #13
0
        static int Main(string[] args)
        {
            int nRet = 0;

            if (args.Length == 0)
            {
                //show usage
                string usage = " no parameters defined\n usage: gac-utility <-i><-u> assembly path";
                Console.WriteLine(usage);
                nRet = -1;
            }
            else if (args[0] == "-i")
            {
                if (System.Reflection.Assembly.LoadFile(args[1]).GetName().GetPublicKey().Length > 0)
                {
                    Publish objPublish = new Publish();
                    Console.WriteLine("Adding {0} to GAC", args[1]);
                    try
                    {
                        objPublish.GacInstall(args[1]);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error {0} Cannot add assembly to GAC!", e);
                        nRet = -1;
                    }
                }
                else
                {
                    Console.WriteLine("Error {0} not signed cannot add to GAC!", args[1]);
                    nRet = -1;
                }
            }
            else if (args[0] == "-u")
            {
                Publish objPublish = new Publish();
                Console.WriteLine("Removing {0} from GAC", args[1]);
                try
                {
                    objPublish.GacRemove(args[1]);
                    nRet = 0;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error {0} Cannot remove assembly from GAC?", e);
                    nRet = -1;
                }
            }
            return(nRet);
        }
Example #14
0
        /// <summary>
        /// Loads our strong signed .net assembly into the GAC.
        /// </summary>
        /// <param name="path">Path to .net assembly.</param>
        private static bool InstallAssembly(string path)
        {
            try
            {
                var publisher = new Publish();
                publisher.GacInstall(path);
            }
            catch (Exception e)
            {
                Console.WriteLine($"An exception occurred while attempting to install .net assembly into GAC {e}");
                return(false);
            }

            return(true);
        }
        internal static OutputQueue RepairAssemblies(string literalPath)
        {
            var output = new OutputQueue();

            try
            {
                var           tempPath  = Path.Combine(literalPath, "temp");
                DirectoryInfo directory = null;
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }
                directory = new DirectoryInfo(tempPath);

                var command = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\expand.exe";
                var wsps    = Directory.GetFiles(literalPath, "*.wsp");
                foreach (var wsp in wsps)
                {
                    var args = "\"" + wsp + "\" -f:*.dll \"" + tempPath + "\"";
                    output.Add(Files.RunCommand(command, args));
                }

                var publish    = new Publish();
                var assemblies = directory.GetFiles("*.dll");
                foreach (var assembly in assemblies)
                {
                    try
                    {
                        output.Add(string.Format(CultureInfo.InvariantCulture, "Adding \"{0}\" to the Global Assembly Cache.", assembly.Name));
                        publish.GacInstall(assembly.FullName);
                    }
                    catch (Exception exception)
                    {
                        output.Add(exception.Message, OutputType.Error, exception.ToString(), exception);
                    }
                }

                directory.Delete(true);
            }
            catch (Exception exception)
            {
                output.Add(exception.Message, OutputType.Error, exception.ToString(), exception);
            }

            return(output);
        }
Example #16
0
        static void Main(string[] args)
        {
            // First, push the Assembly to the GAC
            Console.WriteLine("Attempting to install 'QuickStatsModule' to the Global Assembly Cache.");
            Publish dllGacPublisher = new Publish();

            dllGacPublisher.GacInstall("QuickStatsModule.dll");

            // Next, install it in the ApplicationHost.Config
            using (ServerManager serverManager = new ServerManager())
            {
                Console.WriteLine("Installing 'QuickStatsModule");
                Configuration config     = serverManager.GetApplicationHostConfiguration();
                var           section    = config.GetSection("system.webServer/modules", "");
                var           collection = section.GetCollection();
                var           element    = collection.CreateElement();
                element.Attributes["name"].Value = "QuickStatsModule";
                element.Attributes["type"].Value =
                    $"{nameof(QuickStatsModule)}.{nameof(QuickStatsModule.QuickStatsModule)}, {nameof(QuickStatsModule)}, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fb52c173020a0e2f";
                Console.WriteLine($"Module being installed is: {element.Attributes["name"].Value}");
                Console.WriteLine($"Module install details: {element.Attributes["type"].Value}");

                ConfigurationElement redundantElement = null;
                foreach (var el in collection)
                {
                    if (el.Attributes["name"].Value.Equals(element.Attributes["name"].Value))
                    {
                        redundantElement = el;
                        break;
                    }
                }
                if (redundantElement != null)
                {
                    collection.Remove(redundantElement);
                }
                collection.Add(element);
                serverManager.CommitChanges();
                Console.WriteLine("'QuickStatsModule' successfully installed to the GAC and IIS.");
            }
        }
Example #17
0
        public static void InstallAssembly(string assemblyPath)
        {
            string errorMessage;

            if (String.IsNullOrEmpty(assemblyPath))
            {
                throw new FileNotFoundException("Could not find assembly file to add to the GAC.", assemblyPath);
            }

            try
            {
                Assembly assembly = Assembly.ReflectionOnlyLoadFrom(assemblyPath);
                byte[]   pkey     = assembly.GetName().GetPublicKeyToken();
                if (pkey.Length == 0)
                {
                    errorMessage = string.Format("Cannot install an unsigned assembly into the GAC. '{0}'", assemblyPath);
                    throw new NotSupportedException(errorMessage);
                }
            }
            catch (BadImageFormatException ex)
            {
                errorMessage = string.Format("The assembly is not a CLR assembly. '{0}'", assemblyPath);
                throw new BadImageFormatException(errorMessage, ex);
            }
            catch (FileLoadException ex)
            {
                if (!ex.Message.Contains("has already loaded from a different location"))
                {
                    errorMessage = string.Format("CLR assembly found but could not be loaded. '{0}'", assemblyPath);
                    throw new FileLoadException(errorMessage, ex);
                }
            }

            var publish = new Publish();

            publish.GacInstall(assemblyPath.Trim());
        }
Example #18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates all files that require an update.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateFiles()
        {
            bool fAskedUserToExit = false;             // will be set to true as soon as we have asked user

            using (ProgressDialog dlg = new ProgressDialog())
            {
                dlg.ProgressBar.Maximum = m_FilesToUpdate.Length;
                dlg.Show();
                for (int i = 0; i < m_FilesToUpdate.Length && !dlg.ShouldCancel; i++)
                {
                    UpdateFile file = m_FilesToUpdate[i];
                    Trace.WriteLine(DateTime.Now.ToString() + ": Installing " + file.Name);
                    dlg.InstallText = "Installing " + file.Name;

                    if (file.ExitVs && !fAskedUserToExit)
                    {
                        fAskedUserToExit = true;
                        Process[] processes = Process.GetProcessesByName("devenv");
                        if (processes.Length > 0)
                        {
                            if (MessageBox.Show("Visual Studio needs to close before update can proceed",
                                                "Updates available", MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                ExitVs();
                            }
                            else
                            {
                                Trace.WriteLine(DateTime.Now.ToString() + ": Skipped closing Visual Studio by user's request");
                            }
                        }
                    }

                    try
                    {
                        string extension = Path.GetExtension(file.Name).ToLower();
                        if (extension == ".msi" || extension == ".vsi")
                        {
                            // Install this file
                            Process process = new Process();
                            process.StartInfo.FileName       = Path.Combine(m_UpdatePath, file.Name);
                            process.StartInfo.CreateNoWindow = true;
                            process.StartInfo.Arguments      = "/quiet";
                            process.Start();
                            process.WaitForExit();
                            Trace.WriteLine(DateTime.Now.ToString() + ": Exit code: " + process.ExitCode);
                        }
                        else if (extension == ".dll")
                        {
                            // Install in the GAC
                            string  fileName = Path.Combine(m_UpdatePath, file.Name);
                            Publish publish  = new Publish();
                            publish.GacInstall(fileName);
                            Trace.WriteLine(DateTime.Now.ToString() + ": Installed in GAC");
                        }
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(DateTime.Now.ToString() + ": Got exception installing " +
                                        file.Name + ": " + e.Message);
                        // remove from list of updated files so that we try again
                        m_FileHash.Remove(file.Name);
                    }
                    dlg.ProgressBar.Increment(1);
                }

                RestartVisualStudio(dlg);
                dlg.Close();
            }
        }
Example #19
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            Publish p = new Publish();


            string appPath = Form1.RegistryApplicationDirectory;

            try
            {
                if (_install)
                {
                    System.Environment.SetEnvironmentVariable("GVIEW4_HOME", appPath + @"\", EnvironmentVariableTarget.Machine);
                }
                else
                {
                    System.Environment.SetEnvironmentVariable("GVIEW4_HOME", String.Empty, EnvironmentVariableTarget.Machine);
                }
            }
            catch { }

            DirectoryInfo di = new DirectoryInfo(Path.Combine(appPath, "Framework"));

            FileInfo[] dlls = di.GetFiles("*.dll");

            progressBar1.Minimum = 0;
            progressBar1.Maximum = dlls.Length;
            progressBar1.Value   = 0;

            foreach (FileInfo fi in dlls)
            {
                lblAssembly.Text = fi.FullName;
                this.Refresh();

                if (_install)
                {
                    p.GacInstall(fi.FullName);
                }
                else
                {
                    p.GacRemove(fi.FullName);
                }

                progressBar1.Value++;
                this.Refresh();

                System.Threading.Thread.Sleep(50);
            }

            // Set Envirment Variables
            string PATH      = System.Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
            string PATH2     = String.Empty;
            bool   foundPath = false;

            foreach (string path in PATH.Split(';'))
            {
                if (path.ToLower() != appPath.ToLower())
                {
                    if (PATH2 != String.Empty)
                    {
                        PATH2 += ";";
                    }
                    PATH2 += path;
                }
                else
                {
                    foundPath = true;
                }
            }

            if (_install)
            {
                if (!foundPath)
                {
                    if (PATH2 != String.Empty)
                    {
                        PATH2 += ";";
                    }
                    PATH2 += appPath;

                    System.Environment.SetEnvironmentVariable("PATH", PATH2);
                }
            }
            else
            {
                if (foundPath)
                {
                    System.Environment.SetEnvironmentVariable("PATH", PATH2, EnvironmentVariableTarget.Machine);
                }
            }

            // MapServer.Monitor Service installieren
            //try
            //{
            //    string filename = RegistryApplicationDirectory + @"\gView.MapServer.Monitor.exe";
            //    FileInfo fi = new FileInfo(filename);
            //    if (fi.Exists)
            //    {
            //        if (_install)
            //        {
            //            UInt32 result = (UInt32)mc.InvokeMethod("Install", new object[] { filename });
            //        }
            //        else
            //        {
            //            UInt32 result = (UInt32)mc.InvokeMethod("Uninstall", new object[] { filename });
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Can't " + (_install ? "install" : "uninstall") + " gView.MapServer.Monitor Service...\n" + ex.Message, "Warning");
            //}

            this.Close();
        }
Example #20
0
        static int Main(string[] args)
        {
            bool   doInstall;
            string filePath;
            string finalDirPath;
            string action;
            int    dirArgIndx;

            if (args == null || args.Length == 0)
            {
                ShowUsage();
                return(1);
            }

            if (args[0] == "-u" || args[0] == "/u")
            {
                doInstall  = false;
                filePath   = args[1];
                action     = "Uninstallation";
                dirArgIndx = 2;
            }
            else
            {
                doInstall  = true;
                filePath   = args[0];
                action     = "Installation";
                dirArgIndx = 1;
            }

            try
            {
                if (args.Length == dirArgIndx)
                {
                    finalDirPath = Path.GetDirectoryName(filePath);
                    if (finalDirPath == null || finalDirPath.Length == 0)
                    {
                        finalDirPath = ".";
                    }
                }
                else if (args.Length == (dirArgIndx + 1))
                {
                    finalDirPath = args[dirArgIndx];
                }
                else
                {
                    ShowUsage();
                    return(1);
                }

                Publish publish = new Publish();
                if (!File.Exists(filePath))
                {
                    throw new FileNotFoundException("Given file " +
                                                    filePath + " does not exist.");
                }
                if (!Directory.Exists(finalDirPath))
                {
                    throw new DirectoryNotFoundException("Given directory " +
                                                         finalDirPath + " does not exist.");
                }
                filePath     = Path.GetFullPath(filePath);
                finalDirPath = Path.GetFullPath(finalDirPath);
                RegistryKey dotNETAssemblyFoldersKey =
                    Registry.LocalMachine.OpenSubKey(DOTNETAssemblyFoldersKey, true);
                if (dotNETAssemblyFoldersKey != null)
                {
                    dotNETAssemblyFoldersKey.DeleteSubKey(GeodeProductKey, false);
                }
                if (doInstall)
                {
                    publish.GacInstall(filePath);
                    if (dotNETAssemblyFoldersKey != null)
                    {
                        RegistryKey productKey =
                            dotNETAssemblyFoldersKey.CreateSubKey(GeodeProductKey);
                        if (productKey != null)
                        {
                            productKey.SetValue(null, finalDirPath, RegistryValueKind.String);
                        }
                    }
                }
                else
                {
                    publish.GacRemove(filePath);
                }
                Console.WriteLine("{0} completed successfully.", action);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while performing {0}: {1}{2}\t{3}", action,
                                  ex.GetType(), Environment.NewLine, ex.Message);
                return(1);
            }
            return(0);
        }
Example #21
0
        private void InstallProc(bool install)
        {
            Publish p = new Publish();

            string appPath = this.RegistryApplicationDirectory;

            try
            {
                if (install)
                {
                    System.Environment.SetEnvironmentVariable("GVIEW4_HOME", appPath, EnvironmentVariableTarget.Machine);
                }
                else
                {
                    System.Environment.SetEnvironmentVariable("GVIEW4_HOME", String.Empty, EnvironmentVariableTarget.Machine);
                }
            }
            catch { }

            DirectoryInfo di = new DirectoryInfo(Path.Combine(appPath, "Framework"));

            FileInfo[] dlls = di.GetFiles("*.dll");


            foreach (FileInfo fi in dlls)
            {
                if (install)
                {
                    p.GacInstall(fi.FullName);
                }
                else
                {
                    p.GacRemove(fi.FullName);
                }
            }

            // Set Envirment Variables
            string PATH      = System.Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
            string PATH2     = String.Empty;
            bool   foundPath = false;

            foreach (string path in PATH.Split(';'))
            {
                if (path.ToLower() != appPath.ToLower())
                {
                    if (PATH2 != String.Empty)
                    {
                        PATH2 += ";";
                    }
                    PATH2 += path;
                }
                else
                {
                    foundPath = true;
                }
            }

            if (install)
            {
                if (!foundPath)
                {
                    if (PATH2 != String.Empty)
                    {
                        PATH2 += ";";
                    }
                    PATH2 += appPath;

                    System.Environment.SetEnvironmentVariable("PATH", PATH2);
                }
            }
            else
            {
                if (foundPath)
                {
                    System.Environment.SetEnvironmentVariable("PATH", PATH2, EnvironmentVariableTarget.Machine);
                }
            }
        }