Пример #1
0
        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            // temp storing the running processes
            List <Process> rProcs = new List <Process>();

            foreach (FileInfo filename in filenames)
            {
                Process[] aProcess = Process.GetProcessesByName(filename.Name.Replace(filename.Extension, ""));

                foreach (Process proc in aProcess)
                {
                    try
                    {
                        //are one of the exe's in baseDir running?
                        if (proc.MainModule != null && string.Equals(proc.MainModule.FileName, filename.FullName, StringComparison.OrdinalIgnoreCase)

                            //if the running process is not this wyUpdate instance
                            && !InstallUpdate.ProcessIsSelf(proc.MainModule.FileName))
                        {
                            rProcs.Add(proc);
                        }
                    }
                    catch { }
                }
            }

            // remove any closed processes
            for (int i = 0; i < rProcs.Count; i++)
            {
                if (rProcs[i].HasExited)
                {
                    rProcs.RemoveAt(i);
                    i--;
                }
            }

            e.Result = rProcs.Count > 0 ? rProcs : null;
        }
Пример #2
0
        public static void RollbackRegedCOM(string tempDir)
        {
            List <UninstallFileInfo> rollbackList = new List <UninstallFileInfo>();

            try
            {
                ReadRollbackCOM(Path.Combine(tempDir, "backup\\reggedComList.bak"), rollbackList);
            }
            catch
            {
                return;
            }

            // un-reg COM dlls
            foreach (UninstallFileInfo fileinfo in rollbackList)
            {
                try
                {
                    InstallUpdate.RegisterDllServer(fileinfo.Path, true);
                }
                catch { }
            }
        }
Пример #3
0
        public static void RollbackRegedCOM(string tempDir)
        {
            List <UninstallFileInfo> list = new List <UninstallFileInfo>();

            try
            {
                ReadRollbackCOM(Path.Combine(tempDir, "backup\\reggedComList.bak"), list);
            }
            catch
            {
                return;
            }
            foreach (UninstallFileInfo item in list)
            {
                try
                {
                    InstallUpdate.RegisterDllServer(item.Path, Uninstall: true);
                }
                catch
                {
                }
            }
        }
Пример #4
0
        void InstallUpdates(UpdateOn CurrentlyUpdating)
        {
            switch (CurrentlyUpdating)
            {
            case UpdateOn.FullSelfUpdate:
                SetStepStatus(1, clientLang.SelfUpdate);

                installUpdate = new InstallUpdate
                {
                    //location of old "self" to replace
                    OldSelfLoc      = oldSelfLocation,
                    Filename        = Path.Combine(tempDirectory, updateFilename),
                    OutputDirectory = tempDirectory,
                    FromAutoUpdate  = isAutoUpdateMode
                };

                installUpdate.ProgressChanged += SelfUpdateProgress;
                installUpdate.RunSelfUpdate();
                break;

            case UpdateOn.ExtractSelfUpdate:

                oldSelfLocation = VersionTools.SelfLocation;

                installUpdate = new InstallUpdate
                {
                    // old self is needed for patching
                    OldSelfLoc      = oldSelfLocation,
                    Filename        = Path.Combine(tempDirectory, updateFilename),
                    OutputDirectory = Path.Combine(tempDirectory, "selfupdate")
                };

                installUpdate.ProgressChanged += SelfUpdateProgress;
                installUpdate.JustExtractSelfUpdate();
                break;

            case UpdateOn.InstallSelfUpdate:

                installUpdate = new InstallUpdate
                {
                    //location of old "self" to replace
                    OldSelfLoc      = oldSelfLocation,
                    NewSelfLoc      = newSelfLocation,
                    Filename        = Path.Combine(tempDirectory, updateFilename),
                    OutputDirectory = Path.Combine(tempDirectory, "selfupdate"),
                    FromAutoUpdate  = isAutoUpdateMode
                };

                installUpdate.ProgressChanged += SelfUpdateProgress;
                installUpdate.JustInstallSelfUpdate();
                break;

            case UpdateOn.Extracting:

                // set for auto-updates
                currentlyExtracting = true;

                SetStepStatus(1, clientLang.Extract);

                installUpdate = new InstallUpdate
                {
                    Filename         = Path.Combine(tempDirectory, updateFilename),
                    OutputDirectory  = tempDirectory,
                    TempDirectory    = tempDirectory,
                    ProgramDirectory = baseDirectory,

                    // use the password passed in by commandline (take precedence)
                    // or use the password embedded in the client.wyc file.
                    ExtractPassword = PasswordUpdateCmd ?? update.UpdatePassword
                };

                installUpdate.ProgressChanged += ShowProgress;
                installUpdate.RunUnzipProcess();
                break;

            case UpdateOn.ClosingProcesses:
                SetStepStatus(1, clientLang.Processes);

                installUpdate = new InstallUpdate
                {
                    UpdtDetails      = updtDetails,
                    TempDirectory    = tempDirectory,
                    ProgramDirectory = baseDirectory,

                    // skip ui reporting when updating from a service
                    SkipUIReporting  = UpdatingFromService || updateHelper.IsAService,
                    SkipStartService = updateHelper.IsAService ? updateHelper.FileOrServiceToExecuteAfterUpdate : null
                };

                installUpdate.Rollback        += ChangeRollback;
                installUpdate.ProgressChanged += CheckProcess;
                installUpdate.RunProcessesCheck();
                break;

            case UpdateOn.PreExecute:

                // try to stop the user from forcefuly exiting
                BlockLogOff(true);

                SetStepStatus(1, clientLang.PreExec);

                installUpdate = new InstallUpdate
                {
                    UpdtDetails      = updtDetails,
                    TempDirectory    = tempDirectory,
                    ProgramDirectory = baseDirectory,
                    IsAdmin          = IsAdmin,
                    MainWindowHandle = Handle
                };

                installUpdate.Rollback        += ChangeRollback;
                installUpdate.ProgressChanged += ShowProgress;
                installUpdate.RunPreExecute();
                break;

            case UpdateOn.BackUpInstalling:
                SetStepStatus(1, clientLang.Files);

                installUpdate = new InstallUpdate
                {
                    UpdtDetails      = updtDetails,
                    TempDirectory    = tempDirectory,
                    ProgramDirectory = baseDirectory,

                    // skip ui reporting when updating from a service
                    SkipUIReporting = UpdatingFromService || updateHelper.IsAService
                };

                installUpdate.Rollback        += ChangeRollback;
                installUpdate.ProgressChanged += ShowProgress;
                installUpdate.RunUpdateFiles();
                break;

            case UpdateOn.ModifyReg:
                SetStepStatus(2, clientLang.Registry);

                installUpdate = new InstallUpdate
                {
                    UpdtDetails      = updtDetails,
                    TempDirectory    = tempDirectory,
                    ProgramDirectory = baseDirectory
                };

                installUpdate.Rollback        += ChangeRollback;
                installUpdate.ProgressChanged += ShowProgress;
                installUpdate.RunUpdateRegistry();
                break;

            case UpdateOn.OptimizeExecute:
                SetStepStatus(3, clientLang.Optimize);

                installUpdate = new InstallUpdate
                {
                    UpdtDetails      = updtDetails,
                    TempDirectory    = tempDirectory,
                    ProgramDirectory = baseDirectory,
                    SkipStartService = updateHelper.IsAService ? updateHelper.FileOrServiceToExecuteAfterUpdate : null,
                    IsAdmin          = IsAdmin,
                    MainWindowHandle = Handle
                };

                installUpdate.Rollback        += ChangeRollback;
                installUpdate.ProgressChanged += ShowProgress;
                installUpdate.RunOptimizeExecute();
                break;

            case UpdateOn.WriteClientFile:
                // don't show any status, but begin the thread to being updating the client file

                // Save the client file with the new version
                update.InstalledVersion = ServerFile.NewVersion;

                installUpdate = new InstallUpdate
                {
                    Filename              = clientFileLoc,
                    UpdtDetails           = updtDetails,
                    ClientFileType        = clientFileType,
                    ClientFile            = update,
                    SkipProgressReporting = true,
                    TempDirectory         = tempDirectory,
                    ProgramDirectory      = baseDirectory
                };

                installUpdate.Rollback        += ChangeRollback;
                installUpdate.ProgressChanged += ShowProgress;
                installUpdate.RunUpdateClientDataFile();
                break;

            case UpdateOn.DeletingTemp:
                SetStepStatus(3, clientLang.TempFiles);

                installUpdate = new InstallUpdate
                {
                    TempDirectory = tempDirectory
                };

                installUpdate.ProgressChanged += ShowProgress;
                installUpdate.RunDeleteTemporary();
                break;

            case UpdateOn.Uninstalling:
                // need to pass: client data file loc, delegate, this
                installUpdate = new InstallUpdate
                {
                    Filename = clientFileLoc
                };

                installUpdate.ProgressChanged += UninstallProgress;
                installUpdate.RunUninstall();
                break;
            }
        }
Пример #5
0
        void InstallUpdates(UpdateOn CurrentlyUpdating)
        {
            switch (CurrentlyUpdating)
            {
                case UpdateOn.FullSelfUpdate:
                    SetStepStatus(1, clientLang.SelfUpdate);

                    installUpdate = new InstallUpdate
                                        {
                                            //location of old "self" to replace
                                            OldSelfLoc = oldSelfLocation,
                                            Filename = Path.Combine(tempDirectory, updateFilename),
                                            OutputDirectory = tempDirectory,
                                            FromAutoUpdate = isAutoUpdateMode
                                        };

                    installUpdate.ProgressChanged += SelfUpdateProgress;
                    installUpdate.RunSelfUpdate();
                    break;
                case UpdateOn.ExtractSelfUpdate:

                    oldSelfLocation = VersionTools.SelfLocation;

                    installUpdate = new InstallUpdate
                                        {
                                            // old self is needed for patching
                                            OldSelfLoc = oldSelfLocation,
                                            Filename = Path.Combine(tempDirectory, updateFilename),
                                            OutputDirectory = Path.Combine(tempDirectory, "selfupdate")
                                        };

                    installUpdate.ProgressChanged += SelfUpdateProgress;
                    installUpdate.JustExtractSelfUpdate();
                    break;
                case UpdateOn.InstallSelfUpdate:

                    installUpdate = new InstallUpdate
                                        {
                                            //location of old "self" to replace
                                            OldSelfLoc = oldSelfLocation,
                                            NewSelfLoc = newSelfLocation,
                                            Filename = Path.Combine(tempDirectory, updateFilename),
                                            OutputDirectory = Path.Combine(tempDirectory, "selfupdate"),
                                            FromAutoUpdate = isAutoUpdateMode
                                        };

                    installUpdate.ProgressChanged += SelfUpdateProgress;
                    installUpdate.JustInstallSelfUpdate();
                    break;
                case UpdateOn.Extracting:

                    // set for auto-updates
                    currentlyExtracting = true;

                    SetStepStatus(1, clientLang.Extract);

                    installUpdate = new InstallUpdate
                                        {
                                            Filename = Path.Combine(tempDirectory, updateFilename),
                                            OutputDirectory = tempDirectory,
                                            TempDirectory = tempDirectory,
                                            ProgramDirectory = baseDirectory,

                                            // use the password passed in by commandline (take precedence)
                                            // or use the password embedded in the client.wyc file.
                                            ExtractPassword = PasswordUpdateCmd ?? update.UpdatePassword
                                        };

                    installUpdate.ProgressChanged += ShowProgress;
                    installUpdate.RunUnzipProcess();
                    break;
                case UpdateOn.ClosingProcesses:
                    SetStepStatus(1, clientLang.Processes);

                    installUpdate = new InstallUpdate
                                        {
                                            UpdtDetails = updtDetails,
                                            TempDirectory = tempDirectory,
                                            ProgramDirectory = baseDirectory,

                                            // skip ui reporting when updating from a service
                                            SkipUIReporting = UpdatingFromService || updateHelper.IsAService,
                                            SkipStartService = updateHelper.IsAService ? updateHelper.FileOrServiceToExecuteAfterUpdate : null
                                        };

                    installUpdate.Rollback += ChangeRollback;
                    installUpdate.ProgressChanged += CheckProcess;
                    installUpdate.RunProcessesCheck();
                    break;
                case UpdateOn.PreExecute:

                    // try to stop the user from forcefuly exiting
                    BlockLogOff(true);

                    SetStepStatus(1, clientLang.PreExec);

                    installUpdate = new InstallUpdate
                                        {
                                            UpdtDetails = updtDetails,
                                            TempDirectory = tempDirectory,
                                            ProgramDirectory = baseDirectory,
                                            IsAdmin = IsAdmin,
                                            MainWindowHandle = Handle
                                        };

                    installUpdate.Rollback += ChangeRollback;
                    installUpdate.ProgressChanged += ShowProgress;
                    installUpdate.RunPreExecute();
                    break;
                case UpdateOn.BackUpInstalling:
                    SetStepStatus(1, clientLang.Files);

                    installUpdate = new InstallUpdate
                                        {
                                            UpdtDetails = updtDetails,
                                            TempDirectory = tempDirectory,
                                            ProgramDirectory = baseDirectory,

                                            // skip ui reporting when updating from a service
                                            SkipUIReporting = UpdatingFromService || updateHelper.IsAService
                                        };

                    installUpdate.Rollback += ChangeRollback;
                    installUpdate.ProgressChanged += ShowProgress;
                    installUpdate.RunUpdateFiles();
                    break;
                case UpdateOn.ModifyReg:
                    SetStepStatus(2, clientLang.Registry);

                    installUpdate = new InstallUpdate
                                        {
                                            UpdtDetails = updtDetails,
                                            TempDirectory = tempDirectory,
                                            ProgramDirectory = baseDirectory
                                        };

                    installUpdate.Rollback += ChangeRollback;
                    installUpdate.ProgressChanged += ShowProgress;
                    installUpdate.RunUpdateRegistry();
                    break;
                case UpdateOn.OptimizeExecute:
                    SetStepStatus(3, clientLang.Optimize);

                    installUpdate = new InstallUpdate
                                        {
                                            UpdtDetails = updtDetails,
                                            TempDirectory = tempDirectory,
                                            ProgramDirectory = baseDirectory,
                                            SkipStartService = updateHelper.IsAService ? updateHelper.FileOrServiceToExecuteAfterUpdate : null,
                                            IsAdmin = IsAdmin,
                                            MainWindowHandle = Handle
                                        };

                    installUpdate.Rollback += ChangeRollback;
                    installUpdate.ProgressChanged += ShowProgress;
                    installUpdate.RunOptimizeExecute();
                    break;
                case UpdateOn.WriteClientFile:
                    // don't show any status, but begin the thread to being updating the client file

                    // Save the client file with the new version
                    update.InstalledVersion = ServerFile.NewVersion;

                    installUpdate = new InstallUpdate
                                        {
                                            Filename = clientFileLoc,
                                            UpdtDetails = updtDetails,
                                            ClientFileType = clientFileType,
                                            ClientFile = update,
                                            SkipProgressReporting = true,
                                            TempDirectory = tempDirectory,
                                            ProgramDirectory = baseDirectory
                                        };

                    installUpdate.Rollback += ChangeRollback;
                    installUpdate.ProgressChanged += ShowProgress;
                    installUpdate.RunUpdateClientDataFile();
                    break;
                case UpdateOn.DeletingTemp:
                    SetStepStatus(3, clientLang.TempFiles);

                    installUpdate = new InstallUpdate
                                        {
                                            TempDirectory = tempDirectory
                                        };

                    installUpdate.ProgressChanged += ShowProgress;
                    installUpdate.RunDeleteTemporary();
                    break;
                case UpdateOn.Uninstalling:
                    // need to pass: client data file loc, delegate, this
                    installUpdate = new InstallUpdate
                                        {
                                            Filename = clientFileLoc
                                        };

                    installUpdate.ProgressChanged += UninstallProgress;
                    installUpdate.RunUninstall();
                    break;
            }
        }
Пример #6
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            List <Process> list = new List <Process>();

            foreach (FileInfo filename in filenames)
            {
                Process[] processesByName = Process.GetProcessesByName(filename.Name.Replace(filename.Extension, ""));
                Process[] array           = processesByName;
                foreach (Process process in array)
                {
                    try
                    {
                        if (process.MainModule != null && string.Equals(process.MainModule.FileName, filename.FullName, StringComparison.OrdinalIgnoreCase) && !InstallUpdate.ProcessIsSelf(process.MainModule.FileName))
                        {
                            list.Add(process);
                        }
                    }
                    catch
                    {
                    }
                }
            }
            for (int j = 0; j < list.Count; j++)
            {
                if (list[j].HasExited)
                {
                    list.RemoveAt(j);
                    j--;
                }
            }
            e.Result = ((list.Count > 0) ? list : null);
        }