使用:Windows 7 Pro SP1 x64
我正在尝试使用以下代码删除注册表中的现有值(使用regedit验证存在):
require 'win32/registry'
keyname = 'SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate'
access = Win32::Registry::KEY_ALL_ACCESS
Win32::Registry::HKEY_LOCAL_MACHINE.open(keyname, access) do |reg|
reg.delete_value('SusClientId')
end
其输出产生以下异常:
C:/Ruby200/lib/ruby/2.0.0/win32/registry.rb:768:in `delete_value': The system cannot find the file specified. (Win32::Registry::Error)
from C:/main_script.rb:7:in `block in <main>'
from C:/Ruby200/lib/ruby/2.0.0/win32/registry.rb:389:in `open'
from C:/Ruby200/lib/ruby/2.0.0/win32/registry.rb:496:in `open'
from C:/main_script.rb:6:in `<main>'
任何人都可以帮助我一些见识吗?提前致谢