File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -67,15 +67,7 @@ def read_s(key)
6767 class << self
6868 private
6969 def get_hosts_dir
70- if defined? ( Win32 ::Registry )
71- Registry ::HKEY_LOCAL_MACHINE . open ( TCPIP_NT ) do |reg |
72- reg . read_s_expand ( 'DataBasePath' )
73- end
74- else
75- cmd = "Get-ItemProperty -Path 'HKLM:\\ #{ TCPIP_NT } ' -Name 'DataBasePath' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DataBasePath"
76- output , _ = Open3 . capture2 ( 'powershell' , '-Command' , cmd )
77- output . strip
78- end
70+ get_item_property ( TCPIP_NT , 'DataBasePath' , expand : true )
7971 end
8072
8173 def get_info
@@ -134,10 +126,10 @@ def get_info
134126 [ search . uniq , nameserver . uniq ]
135127 end
136128
137- def get_item_property ( path , name )
129+ def get_item_property ( path , name , expand : false )
138130 if defined? ( Win32 ::Registry )
139131 Registry ::HKEY_LOCAL_MACHINE . open ( path ) do |reg |
140- reg . read_s ( key )
132+ expand ? reg . read_s_expand ( name ) : reg . read_s ( name )
141133 rescue Registry ::Error
142134 ""
143135 end
You can’t perform that action at this time.
0 commit comments