public bool CheckEndCreateRegFileAndStartupBatchFile(OSVersions os, ConfigClass configClass) { bool totalcheck = true; try { if (File.Exists(_regFilepath + @"\firstLogon.exe")) { _checkRegKeySettingsForOtherUsers.Add(true); } else { _checkRegKeySettingsForOtherUsers.Add(false); } if (File.Exists(_regFilepath + @"\firstLogon.bat")) { _checkRegKeySettingsForOtherUsers.Add(true); } else { _checkRegKeySettingsForOtherUsers.Add(false); } FileHandling _fileHandling = new FileHandling(); List <string> regSettings = new List <string>(); regSettings = _fileHandling.ReadWholeFile(_regFilepath + @"\firstLogon.reg"); foreach (string str in configClass.GetScriptHandling.RegistrySettings) { if (regSettings.Contains(str)) { _checkRegKeySettingsForOtherUsers.Add(true); } else { _checkRegKeySettingsForOtherUsers.Add(false); } } foreach (bool b in _checkRegKeySettingsForOtherUsers) { if (!b) { totalcheck = false; return(totalcheck); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check start up files for accounts are created", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check start up files for accounts are created", ex.Message)); } return(totalcheck); }
public void RestoreSettings() { MessageBoxButtons buttons = MessageBoxButtons.OKCancel; DialogResult result; result = MessageBox.Show("Windows will restore your system to the state it was before adding the security settings. \n Before you proceed, save any open files and close all programs", "System restore", buttons); if (result == System.Windows.Forms.DialogResult.OK) { FileHandling fileHandling = new FileHandling(); string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\ConfigFiles\restorePoint.inf"; string restorPoint = fileHandling.ReadWholeFile(path)[0]; GetScriptHandling.RestoreSettings(restorPoint); } }
public void ReadMBSAlog(ConfigClass configClass) { try { string mbsaLog = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\MBSAlog.txt"; if (File.Exists(mbsaLog)) { FileHandling _fileHandling = new FileHandling(); foreach (string str in _fileHandling.ReadWholeFile(mbsaLog)) { MBSAlogs.Add(new MBSAlogItem(str)); } } } catch (Exception ex) { configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Read MBSA log", ex.Message)); } }
public void AddKey(string username, string password) { List <string> pwRoles = new List <string>(); pwRoles.Clear(); string text = Encryption.Encrypt(username + "|" + password, Key); pwRoles.Add(text); try { if (!File.Exists(_encryptionPath)) { CreateEncryptedKeyFile(); // _fileStream = new FileStream(_encryptionPath, FileMode.Append, FileAccess.Write); } else { //_fileStream = new FileStream(_encryptionPath, FileMode.Append, FileAccess.Write); } if (GetKey(username) != null) { foreach (string str in _fhEncr.ReadWholeFile(_encryptionPath)) { string encrypted = Encryption.Decrypt(str, Key); string[] split = encrypted.Split('|'); if (split[0] != username) { pwRoles.Add(str); } } if (_fileStream != null) { _fileStream.Close(); } File.Delete(_encryptionPath); CreateEncryptedKeyFile(); _fileStream = new FileStream(_encryptionPath, FileMode.Append, FileAccess.Write); _streamWriter = new StreamWriter(_fileStream); _streamWriter.WriteLine(text); foreach (string pwKey in pwRoles) { _streamWriter.WriteLine(pwKey); } } else { _fileStream = new FileStream(_encryptionPath, FileMode.Append, FileAccess.Write); _streamWriter = new StreamWriter(_fileStream); _streamWriter.WriteLine(text); } } catch (IOException) { } finally { if (_streamWriter != null) { _streamWriter.Close(); } if (_fileStream != null) { _fileStream.Close(); } } }