# A small ruby script that will update the Windows registry # so that all folders for the current profile are open with # 'sort_by: name' # # licence: GPL # author: Yoann Guillot require 'win32/registry' class Win32::Registry @count = 0 def self.recurse(key) @count += 1 key.each_key { |subkey, wtime| key.open(subkey, KEY_READ | KEY_WRITE) { |k| recurse(k) } } begin if key.read_i('Sort') != 0 puts key.name key.write_i('Sort', 0) # sort by name end if key.read_i('Sortdir') != 1 key.write_i('Sortdir', 1) # ascending end rescue Error # no way to check if a key exists... ? end end puts 'running' HKEY_CURRENT_USER.open('Software\\Microsoft\\Windows') { |key| key.open('Shell\\Bags', KEY_READ | KEY_WRITE) { |k| recurse(k) } puts 'still running' key.open('ShellNoRoam\\Bags', KEY_READ | KEY_WRITE) { |k| recurse(k) } rescue nil # XP only ? } puts "seen #@count entries" end puts 'done, press enter' gets