Dizzy13 Posted June 12, 2017 Report Posted June 12, 2017 (edited) Salut! Sa spunem ca in HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache am salvat un registru cu numele "C:\test\test.exe" si altul cu numele "C:\Program Files\test\test.exe", cum pot face sa stearga automat orice registru care contine "test.exe"? registryKey = My.Computer.Registry.CurrentUser.OpenSubKey("SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache", True) registryKey.DeleteValue(String.Concat("*test.exe*"), True) ' ceva de genul registryKey.Close() Sau daca aveti idee de o alta metoda cu care as putea sterge automat orice log din programul LastActivityView. Multumesc anticipat! Edited June 12, 2017 by Dizzy13 Quote
Active Members MrGrj Posted June 12, 2017 Active Members Report Posted June 12, 2017 // asa stergi toate event logurile // te descurci probabil sa faci ceva regex sa stergi ce vrei tu foreach (var log in EventLog.GetEventLogs()) { log.Clear(); log.Dispose(); } Quote
Maximus Posted June 12, 2017 Report Posted June 12, 2017 Trebuie sa studiezi ceva de genu https://www.google.co.uk/?gws_rd=ssl#q=vb.net+monitor+registry+key+for+changes Quote
gigiRoman Posted June 13, 2017 Report Posted June 13, 2017 (edited) using Microsoft.Win32; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RegistryValue { class Program { static string COMPANY = ""; static void Main(string[] args) { string path = @"SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache"; string keyToDelete = "test.exe"; string appName1 = @"C:\Program Files\test\test.exe"; string appName2 = @"C:\test\test.exe"; InsertRegValue(path, appName1, "aaaa"); InsertRegValue(path, appName2, "bbbbbb"); foreach (var item in GetRegValue(path)) { if (item.Contains(keyToDelete)) DeleteRegValue(path, item); } } static private bool InsertRegValue(String path, String regKey, String regValue) { // Write path to the registry RegistryKey key = Registry.CurrentUser.OpenSubKey(path, true); if (key.OpenSubKey(path) == null) key.CreateSubKey(path); try { key.SetValue(regKey, regValue); return true; } catch (Exception) { return false; } } static private String[] GetRegValue(String path) { // Write path to the registry RegistryKey key = Registry.CurrentUser.OpenSubKey(path); if (key != null) { try { return (String[])key.GetValueNames(); } catch (Exception) { return new String[] { }; } } return new String[] { }; } static private void DeleteRegValue(String path, String regKey) { using (RegistryKey key = Registry.CurrentUser.OpenSubKey(path, true)) { try { if (key == null) { // Key doesn't exist. Do whatever you want to handle // this case } else { key.DeleteValue(regKey); } } catch (Exception ex) { } } } } } mai intai insereaza in in registry 2 valori pentru testexe 1 si testexe2, apoi ia elementele din path si verifica daca au in componenta cheia cautata, daca da sterge registrul. @MrGrj event logurile nu cred ca au treaba cu registrii. @Dizzy13 daca ai nevoie si de exe sa imi zici. consola trebuie rulata ca administrator. Edited June 13, 2017 by gigiRoman Quote