Exemple #1
0
        public static LibaryFile EvaluateLibary()
        {
            LibaryFile WinRAR   = CheckWinRAR(); // CheckWinRAR
            LibaryFile SevenZip = Check7Zip();   // Check7Zip

            if (WinRAR.IsInstalled())
            {
                return(WinRAR);
            }
            else if (SevenZip.IsInstalled())
            {
                return(SevenZip);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Remove telementry and only extract basic drivers
        /// </summary>
        private static void MakeInstaller()
        {
            Console.WriteLine();
            Console.Write("Making installer . . . ");

            LibaryFile libaryFile = LibaryHandler.EvaluateLibary();

            string[] filesToExtract = { "Display.Driver", "NVI2", "EULA.txt", "license.txt", "ListDevices.txt", "setup.cfg", "setup.exe" };

            File.WriteAllLines(savePath + @"\" + "inclList.txt", filesToExtract);

            string fullDriverPath = @"""" + savePath + @"\" + driverFileName + @"""";

            if (libaryFile.libary == LibaryHandler.Libary.WINRAR)
            {
                using (Process WinRAR = new Process())
                {
                    WinRAR.StartInfo.FileName         = libaryFile.InstallLocation + "winrar.exe";
                    WinRAR.StartInfo.WorkingDirectory = savePath;
                    WinRAR.StartInfo.Arguments        = "X " + fullDriverPath + @" -N@""inclList.txt""";
                    WinRAR.StartInfo.UseShellExecute  = false;
                    WinRAR.Start();
                    WinRAR.WaitForExit();
                }
            }
            else if (libaryFile.libary == LibaryHandler.Libary.SEVENZIP)
            {
                using (Process SevenZip = new Process()) {
                    SevenZip.StartInfo.FileName         = libaryFile.InstallLocation + "7zG.exe";
                    SevenZip.StartInfo.WorkingDirectory = savePath;
                    SevenZip.StartInfo.Arguments        = "x " + fullDriverPath + @" @inclList.txt";
                    SevenZip.StartInfo.UseShellExecute  = false;
                    SevenZip.Start();
                    SevenZip.WaitForExit();
                }
            }



            Console.Write("OK!");
            Console.WriteLine();
        }
        /// <summary>
        /// Remove telementry and only extract basic drivers
        /// </summary>
        private static void MakeInstaller(bool silent)
        {
            Console.WriteLine();
            Console.Write("Making installer . . . ");

            int        error      = 0;
            LibaryFile libaryFile = LibaryHandler.EvaluateLibary();

            string[] filesToExtract = { "Display.Driver", "NVI2", "EULA.txt", "license.txt", "ListDevices.txt", "setup.cfg", "setup.exe" };

            try {
                File.WriteAllLines(savePath + "inclList.txt", filesToExtract);
            } catch (Exception ex) {
                error++;
                Console.Write("ERROR!");
                Console.WriteLine();
                Console.WriteLine(ex.ToString());
            }

            string fullDriverPath = @"""" + savePath + driverFileName + @"""";

            if (libaryFile.libary == LibaryHandler.Libary.WINRAR)
            {
                using (Process WinRAR = new Process()) {
                    WinRAR.StartInfo.FileName         = libaryFile.InstallLocation + "winrar.exe";
                    WinRAR.StartInfo.WorkingDirectory = savePath;
                    WinRAR.StartInfo.Arguments        = "X " + fullDriverPath + @" -N@""inclList.txt""";
                    if (silent)
                    {
                        WinRAR.StartInfo.Arguments += " -ibck -y";
                    }
                    WinRAR.StartInfo.UseShellExecute = false;
                    try {
                        WinRAR.Start();
                        WinRAR.WaitForExit();
                    } catch (Exception ex) {
                        error++;
                        Console.Write("ERROR!");
                        Console.WriteLine();
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else if (libaryFile.libary == LibaryHandler.Libary.SEVENZIP)
            {
                using (Process SevenZip = new Process()) {
                    if (silent)
                    {
                        SevenZip.StartInfo.FileName = libaryFile.InstallLocation + "7z.exe";
                    }
                    else
                    {
                        SevenZip.StartInfo.FileName = libaryFile.InstallLocation + "7zG.exe";
                    }
                    SevenZip.StartInfo.WorkingDirectory = savePath;
                    SevenZip.StartInfo.Arguments        = "x " + fullDriverPath + @" @inclList.txt";
                    if (silent)
                    {
                        SevenZip.StartInfo.Arguments += " -y";
                    }
                    SevenZip.StartInfo.UseShellExecute = false;
                    SevenZip.StartInfo.CreateNoWindow  = true; // don't show the console in our console!
                    try {
                        Thread.Sleep(1000);
                        SevenZip.Start();
                        SevenZip.WaitForExit();
                    } catch (Exception ex) {
                        error++;
                        Console.Write("ERROR!");
                        Console.WriteLine();
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else
            {
                Console.WriteLine("Could not identify a possible extractor! We should panic.");
            }

            if (error == 0)
            {
                Console.Write("OK!");
                Console.WriteLine();
            }
        }
        /// <summary>
        /// Remove telementry and only extract basic drivers
        /// </summary>
        private static void MakeInstaller(bool silent)
        {
            Console.WriteLine();
            Console.Write("Making installer . . . ");

            bool       error      = false;
            LibaryFile libaryFile = LibaryHandler.EvaluateLibary();

            string[] filesToExtract = { "Display.Driver", "NVI2", "EULA.txt", "license.txt", "ListDevices.txt", "setup.cfg", "setup.exe" };

            try {
                File.WriteAllLines(savePath + "inclList.txt", filesToExtract);
            } catch (Exception ex) {
                error = true;
                Console.Write("ERROR!");
                Console.WriteLine();
                Console.WriteLine(ex.ToString());
            }

            string fullDriverPath = @"""" + savePath + driverFileName + @"""";

            if (libaryFile.libary == LibaryHandler.Libary.WINRAR)
            {
                using (Process WinRAR = new Process()) {
                    WinRAR.StartInfo.FileName         = libaryFile.InstallLocation + "winrar.exe";
                    WinRAR.StartInfo.WorkingDirectory = savePath;
                    WinRAR.StartInfo.Arguments        = $@"X {fullDriverPath} -N@""inclList.txt""";
                    if (silent)
                    {
                        WinRAR.StartInfo.Arguments += " -ibck -y";
                    }
                    WinRAR.StartInfo.UseShellExecute = false;

                    try {
                        WinRAR.Start();
                        WinRAR.WaitForExit();
                    } catch (Exception ex) {
                        error = true;
                        Console.Write("ERROR!");
                        Console.WriteLine();
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else if (libaryFile.libary == LibaryHandler.Libary.SEVENZIP)
            {
                using (Process SevenZip = new Process()) {
                    if (silent)
                    {
                        SevenZip.StartInfo.FileName = libaryFile.InstallLocation + "7z.exe";
                    }
                    else
                    {
                        SevenZip.StartInfo.FileName = libaryFile.InstallLocation + "7zG.exe";
                    }
                    SevenZip.StartInfo.WorkingDirectory = savePath;
                    SevenZip.StartInfo.Arguments        = $"x {fullDriverPath} @inclList.txt";
                    if (silent)
                    {
                        SevenZip.StartInfo.Arguments += " -y";
                    }
                    SevenZip.StartInfo.UseShellExecute = false;
                    SevenZip.StartInfo.CreateNoWindow  = true; // don't show the console in our console!

                    try {
                        Thread.Sleep(1000);
                        SevenZip.Start();
                        SevenZip.WaitForExit();
                    } catch (Exception ex) {
                        error = true;
                        Console.Write("ERROR!");
                        Console.WriteLine();
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else
            {
                Console.WriteLine("Could not identify a possible extractor! We should panic.");
                error = true;
            }

            // remove new EULA files from the installer config, or else the installer throws error codes
            // thanks to https://github.com/cywq
            if (!error)
            {
                XmlDocument xmlDocument = new XmlDocument();
                string      setupFile   = savePath + "setup.cfg";
                xmlDocument.Load(setupFile);

                string[] LinesToDelete = { "${{EulaHtmlFile}}", "${{FunctionalConsentFile}}", "${{PrivacyPolicyFile}}" };
                foreach (string line in LinesToDelete)
                {
                    XmlElement node = (XmlElement)xmlDocument.DocumentElement.SelectSingleNode("/setup/manifest/file[@name=\"" + line + "\"]");
                    if (node != null)
                    {
                        node.ParentNode.RemoveChild(node);
                    }
                }
                xmlDocument.Save(setupFile);
            }

            if (!error)
            {
                Console.Write("OK!");
                Console.WriteLine();

                try {
                    File.Delete(savePath + driverFileName);
                    File.Delete(savePath + "inclList.txt");
                    Console.WriteLine("Cleaned up: driver archive and inclList.txt");
                } catch {
                    Console.WriteLine("Could not cleanup: driver archive or inclList.txt");
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Remove telementry and only extract basic drivers
        /// </summary>
        private static void MakeInstaller(bool silent)
        {
            Console.WriteLine();
            Console.Write("Making installer . . . ");

            bool          error          = false;
            LibaryFile    libaryFile     = LibaryHandler.EvaluateLibary();
            List <string> filesToExtract = new List <string> {
                "Display.Driver", "NVI2", "EULA.txt", "license.txt", "ListDevices.txt", "setup.cfg", "setup.exe"
            };

            if (driverComponentsToInstall != null && driverComponentsToInstall.Count > 0)
            {
                var lowerCaseEqualityComparer = new AnonymousEqualityComparer <string>((s1, s2) => s1.ToLower().Equals(s2.ToLower()), s => s.ToLower().GetHashCode());
                var collection = driverComponentsToInstall.Where(s => !filesToExtract.Contains(s, lowerCaseEqualityComparer));
                filesToExtract.AddRange(collection);
            }

            try {
                File.WriteAllLines(savePath + "inclList.txt", filesToExtract);
            } catch (Exception ex) {
                error = true;
                Console.Write("ERROR!");
                Console.WriteLine();
                Console.WriteLine(ex.ToString());
            }

            string fullDriverPath = @"""" + savePath + driverFileName + @"""";

            if (libaryFile.libary == LibaryHandler.Libary.WINRAR)
            {
                using (Process WinRAR = new Process()) {
                    WinRAR.StartInfo.FileName         = libaryFile.InstallLocation + "winrar.exe";
                    WinRAR.StartInfo.WorkingDirectory = savePath;
                    WinRAR.StartInfo.Arguments        = "X " + fullDriverPath + @" -N@""inclList.txt""";
                    if (silent)
                    {
                        WinRAR.StartInfo.Arguments += " -ibck -y";
                    }
                    WinRAR.StartInfo.UseShellExecute = false;
                    try {
                        WinRAR.Start();
                        WinRAR.WaitForExit();
                    } catch (Exception ex) {
                        error = true;
                        Console.Write("ERROR!");
                        Console.WriteLine();
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else if (libaryFile.libary == LibaryHandler.Libary.SEVENZIP)
            {
                using (Process SevenZip = new Process()) {
                    if (silent)
                    {
                        SevenZip.StartInfo.FileName = libaryFile.InstallLocation + "7z.exe";
                    }
                    else
                    {
                        SevenZip.StartInfo.FileName = libaryFile.InstallLocation + "7zG.exe";
                    }
                    SevenZip.StartInfo.WorkingDirectory = savePath;
                    SevenZip.StartInfo.Arguments        = "x " + fullDriverPath + @" @inclList.txt";
                    if (silent)
                    {
                        SevenZip.StartInfo.Arguments += " -y";
                    }
                    SevenZip.StartInfo.UseShellExecute = false;
                    SevenZip.StartInfo.CreateNoWindow  = true; // don't show the console in our console!
                    try {
                        Thread.Sleep(1000);
                        SevenZip.Start();
                        SevenZip.WaitForExit();
                    } catch (Exception ex) {
                        error = true;
                        Console.Write("ERROR!");
                        Console.WriteLine();
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else
            {
                Console.WriteLine("Could not identify a possible extractor! We should panic.");
                error = true;
            }

            // remove new EULA files from the installer config, or else the installer throws error codes
            // thanks to https://github.com/cywq
            if (!error)
            {
                XmlDocument xmlDocument = new XmlDocument();
                string      setupFile   = savePath + "setup.cfg";
                xmlDocument.Load(setupFile);

                string[] LinesToDelete = { "${{EulaHtmlFile}}", "${{FunctionalConsentFile}}", "${{PrivacyPolicyFile}}" };
                foreach (string line in LinesToDelete)
                {
                    XmlElement node = (XmlElement)xmlDocument.DocumentElement.SelectSingleNode("/setup/manifest/file[@name=\"" + line + "\"]");
                    if (node != null)
                    {
                        node.ParentNode.RemoveChild(node);
                    }
                }
                xmlDocument.Save(setupFile);
            }

            if (!error)
            {
                Console.Write("OK!");
                Console.WriteLine();
            }
        }