Example #1
0
 private void AddPc1(object sender, RoutedEventArgs e)
 {
     if (CheckList() && !Comps.isNew(pcName01.Text))
     {
         DataBase.Update(pcName01.Text, AdmPass01.Text, BiosPass01.Text, pcModel01.SelectedItem.ToString());
     }
     else if (CheckList() && Comps.isNew(pcName01.Text))
     {
         DataBase.Add(pcName01.Text, AdmPass01.Text, BiosPass01.Text, pcModel01.SelectedItem.ToString());
     }
     else if (!CheckList() && !Comps.isNew(pcName01.Text))
     {
         if (MessageBox.Show("Не все пункты отмечены. Вы уверены что хотите добавить", "Замечены пропуски.", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             DataBase.Update(pcName01.Text, AdmPass01.Text, BiosPass01.Text, pcModel01.Text);
         }
         else
         {
             return;
         }
     }
     else if (!CheckList() && Comps.isNew(pcName01.Text))
     {
         if (MessageBox.Show("Не все пункты отмечены. Вы уверены что хотите добавить", "Замечены пропуски.", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
         {
             DataBase.Add(pcName01.Text, AdmPass01.Text, BiosPass01.Text, pcModel01.SelectedItem.ToString());
         }
     }
     pcName01.IsReadOnly = false;
     AdmPass01.Text      = "";
     BiosPass01.Text     = "";
 }
Example #2
0
        private void OnReady(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Для автоматической настройки необходимо иметь права доступа на удаленной машине, а так же включить службу 'Удаленный реестр' и отключить брэндмауэр",
                                "Подготовка установки", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                try
                {
                    if (Comps.isNew(pcName01.Text))
                    {
                        DataBase.Add(pcName01.Text, AdmPass01.Text, BiosPass01.Text, pcModel01.Text);
                    }
                    else
                    {
                        DataBase.Update(pcName01.Text, AdmPass01.Text, BiosPass01.Text, pcModel01.Text);
                    }

                    RemoteInstall install = new RemoteInstall(AdmPass01.Text, BiosPass01.Text);
                    install.InstallFinished += ClearPage;
                    install.ProgressChange  += ProgressChecking;
                    install.Install(pcName01.Text, SoftType.Text, pcModel01.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    File.AppendAllText($@"{Environment.CurrentDirectory}\Logs", $"{DateTime.Now}:{ex.Message}");
                }
            }
        }
Example #3
0
        private void isNew(string PcName)
        {
            pcName01.IsReadOnly = true;
            if (!Comps.isNew(PcName))
            {
                Comps comp = Comps.GetPasswords(pcName01.Text);
                if (comp.AdmPass.Length < Settings2.Default.admPassLenght)
                {
                    if (MessageBox.Show("Длинна пароля локального админа меньше установленной длинны. Хотите сгенерировать новый пароль?", "Пароль не соответствует длинне", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        AdmPass01.Text = PassGenerator.GetAdmPass();
                    }
                    else
                    {
                        AdmPass01.Text = comp.AdmPass;
                    }
                }
                else
                {
                    if (MessageBox.Show("Хотите создать новый пароль?", "Пароль локального адина", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                    {
                        AdmPass01.Text = PassGenerator.GetAdmPass();
                    }
                    else
                    {
                        AdmPass01.Text = comp.AdmPass;
                    }
                }

                if (comp.BiosPass.Length < Settings2.Default.biosPassLenght)
                {
                    if (MessageBox.Show("Длинна пароля BIOS меньше установленной длинны. Хотите сгенерировать новый пароль?", "Пароль не соответствует длинне", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        BiosPass01.Text = PassGenerator.GetBiosPass();
                    }
                    else
                    {
                        BiosPass01.Text = comp.BiosPass;
                    }
                }
                else
                {
                    if (MessageBox.Show("Хотите создать новый пароль?", "Пароль BIOS", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                    {
                        BiosPass01.Text = PassGenerator.GetBiosPass();
                    }
                    else
                    {
                        BiosPass01.Text = comp.BiosPass;
                    }
                }
            }
            else
            {
                PassGenerator.GetPass(AdmPass01, BiosPass01);
            }
        }
Example #4
0
        public void Install(string pcName, string softType, string modelName)
        {
            if (Settings2.Default.scriptFolder == "")
            {
                MessageBox.Show("Необходимо указать папку для создания временных скриптов.");
                return;
            }
            //check for psExec extention
            if (Settings2.Default.psExec_Path == "")
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Filter      = "EXE(*.exe) |*.exe";
                open.Title       = "Укажите размещение psExec";
                open.FilterIndex = 2;
                if (open.ShowDialog() == true)
                {
                    Settings2.Default.psExec_Path = open.FileName;
                    Settings2.Default.Save();
                }
            }
            if (password.Length < 1)
            {
                pass = new Password();
                if (pass.ShowDialog() == true)
                {
                    password = pass.Pass;
                }
            }

            XMLWorker.GetXML();
            Task.Run(() => InstallDrivers(pcName, modelName));
            Task.Run(() => InstallSoft(pcName, softType));

            if (Comps.isNew(pcName))
            {
                if (CreateSettings(pcName, FindPasswords(XMLWorker.GetSettings())))
                {
                    Task.Run(() => SetSettings(pcName));
                }
                if (XMLWorker.GetBiosScript(modelName) != "" && XMLWorker.GetBiosScript(modelName) != null)
                {
                    CreateBiosSettings(pcName, FindPasswords(XMLWorker.GetBiosScript(modelName)));
                    Task.Run(() => ResetBiosPassword(pcName, modelName));
                    Task.Run(() => BiosSettingsInstalling(pcName));
                    Task.Run(() => Thread.Sleep(120000));
                    Task.Run(() => SetBiosPassword(pcName, modelName));
                }
            }
            else
            {
                if (CreateSettings(pcName, FindPasswords(XMLWorker.GetSettings())))
                {
                    Task.Run(() => SetSettings(pcName));
                }
                Finish(this, EventArgs.Empty);
            }
        }
Example #5
0
        private void OnEnter_Click(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                Status.Content    = "";
                ProgressBar.Value = 0;
                SoftType.Items.Clear();
                pcModel01.Items.Clear();
                foreach (string type in XMLWorker.GetProgramTypes())
                {
                    SoftType.Items.Add(type);
                }
                foreach (string model in DataBase.GetModelList())
                {
                    pcModel01.Items.Add(model);
                }
                pcName01.IsReadOnly = true;
                if (!Comps.isNew(pcName01.Text))
                {
                    Comps comp = Comps.GetPasswords(pcName01.Text);
                    if (comp.AdmPass.Length < Settings2.Default.admPassLenght)
                    {
                        if (MessageBox.Show("Длинна пароля локального админа меньше установленной длинны. Хотите сгенерировать новый пароль?", "Пароль не соответствует длинне", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            AdmPass01.Text = PassGenerator.GetAdmPass();
                        }
                        else
                        {
                            AdmPass01.Text = comp.AdmPass;
                        }
                    }
                    else
                    {
                        if (MessageBox.Show("Хотите создать новый пароль?", "Пароль локального адина", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                        {
                            AdmPass01.Text = PassGenerator.GetAdmPass();
                        }
                        else
                        {
                            AdmPass01.Text = comp.AdmPass;
                        }
                    }

                    if (comp.BiosPass.Length < Settings2.Default.biosPassLenght)
                    {
                        if (MessageBox.Show("Длинна пароля BIOS меньше установленной длинны. Хотите сгенерировать новый пароль?", "Пароль не соответствует длинне", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            BiosPass01.Text = PassGenerator.GetBiosPass();
                        }
                        else
                        {
                            BiosPass01.Text = comp.BiosPass;
                        }
                    }
                    else
                    {
                        if (MessageBox.Show("Хотите создать новый пароль?", "Пароль BIOS", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
                        {
                            BiosPass01.Text = PassGenerator.GetBiosPass();
                        }
                        else
                        {
                            BiosPass01.Text = comp.BiosPass;
                        }
                    }
                    string backup   = $@"{pcName01.Text} {AdmPass01.Text} {BiosPass01.Text}";
                    byte[] array    = Encoding.Default.GetBytes(backup);
                    string tempPath = $@"{Environment.CurrentDirectory}\backupPassword";
                    using (FileStream fs = new FileStream(tempPath, FileMode.Append))
                    {
                        fs.Write(array, 0, array.Length);
                    }
                    File.SetAttributes(tempPath, FileAttributes.Hidden);
                }
                else
                {
                    AdmPass01.Text  = PassGenerator.GetAdmPass();
                    BiosPass01.Text = PassGenerator.GetBiosPass();
                }
            }
        }