Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        void InstallUpdates(UpdateOn CurrentlyUpdating)
        {
            switch (CurrentlyUpdating)
            {
                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.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;
            }
        }
Ejemplo n.º 3
0
        void InstallUpdates(UpdateOn CurrentlyUpdating)
        {
            switch (CurrentlyUpdating)
            {
            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.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;
            }
        }