Example #1
0
        static void Main(string[] args)
        {
            var logsFile = new Utils.Logs(logFile);

            var    uninstallStringServer = GetUninstallStringOfApplication(productServerName);
            var    uninstallStringAgent  = GetUninstallStringOfApplication(productAgentName);
            string message = "";

            if ((uninstallStringAgent == "") && (uninstallStringServer == ""))
            {
                message = "FileMonitor is not installed on this computer!";
                logsFile.WriteMessageToLogFile(message);
                Console.WriteLine(message);
                Thread.Sleep(1000);
            }
            else
            {
                if (uninstallStringAgent != "")
                {
                    message = String.Format("Application '{0}' will be uninstalled !", productAgentName);
                    logsFile.WriteMessageToLogFile(message);
                    Console.WriteLine(message);
                    RunUninstallCommand(uninstallStringAgent);
                }
                if (uninstallStringServer != "")
                {
                    message = String.Format("Application '{0}' will be uninstalled !", productServerName);
                    logsFile.WriteMessageToLogFile(message);
                    Console.WriteLine(message);
                    RunUninstallCommand(uninstallStringServer);
                }
            }
        }
Example #2
0
        private static void RunServerInstaller(string path)
        {
            if (Directory.Exists(path))
            {
                RunServerInstallerKit(path);
            }
            else
            {
                var logMessages = "This path: " + path + " doesn't exists !";

                var logsFile = new Utils.Logs(logFile);
                logsFile.WriteMessageToLogFile(logMessages);
            }
        }
Example #3
0
        private static void PerformInstallerCommands(string fullPathServerInstaller, string fullPathInstallConfig, string programDataInstallConfig)
        {
            var logsFile = new Utils.Logs(logFile);

            if (File.Exists(programDataInstallConfig))
            {
                try
                {
                    File.Delete(programDataInstallConfig);
                }
                catch (Exception e)
                {
                    logsFile.WriteMessageToLogFile("Exception when try to delete silentconfig file  : " + e.Message);
                }
            }
            Process.Start(fullPathServerInstaller, "/i /q");
            Console.WriteLine("Installing FileMonitor Server...");
            var configProcess = new Utils.Process(processConfigName);

            bool proceessIsRunning = configProcess.WaitUntilProcessRunning();

            if (proceessIsRunning)
            {
                configProcess.GetProcessesListAndKillProcess();
                File.Copy(fullPathInstallConfig, programDataInstallConfig, true);

                Console.WriteLine("Configure FileMonitor Server...");
                var result = configProcess.LaunchProcessWithArgsAndWaitForProcessToFinish(postInstallConfigFile, "/install", 60000);
                if (result != 0)
                {
                    var errorMessage = "An error was occured on PostInstallConfig or timed out!!";
                    logsFile.WriteMessageToLogFile(errorMessage);
                }
                else
                {
                    var Message = "Application was succesfully installed !!!";
                    Console.WriteLine(Message);
                    logsFile.WriteMessageToLogFile(Message);
                }
            }
            else
            {
                var errorMessage = "Something was wrong or timed out!!";
                logsFile.WriteMessageToLogFile(errorMessage);
            }
        }
Example #4
0
        private static void RunServerInstallerKit(string path)
        {
            string fullPathServerInstaller  = Path.Combine(path, serverInstallerKit);
            string fullPathInstallConfig    = Path.Combine(path, installConfigFile);
            string programDataInstallConfig = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), installConfigFile);

            if (File.Exists(fullPathServerInstaller) && File.Exists(fullPathInstallConfig))
            {
                PerformInstallerCommands(fullPathServerInstaller, fullPathInstallConfig, programDataInstallConfig);
            }
            else
            {
                var errorMessage = "Some required files are missing";

                var logsFile = new Utils.Logs(logFile);
                logsFile.WriteMessageToLogFile(errorMessage);
            }
        }
Example #5
0
        private static void RunUninstallCommand(string uninstallString)
        {
            var    logsFile   = new Utils.Logs(logFile);
            string arguments  = " /quiet /norestart ";
            string GUID       = uninstallString.Substring(14);
            string parameters = "/X " + GUID + arguments;
            string message    = "";

            Console.WriteLine(" Uninstall command  is: MsiExec.exe{0}\n", parameters);
            try
            {
                var process = Process.Start("MsiExec.exe", parameters);
                process.WaitForExit();
                message = String.Format("Exit Code MsiExec: {0} ", process.ExitCode);
            }
            catch (Exception e)
            {
                message = String.Format("Exception MsiExec Message: {0} ", e.Message);
            }
            Console.WriteLine(message);
            logsFile.WriteMessageToLogFile(message);
        }