File tree 1 file changed +3
-11
lines changed
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)
67
67
class << self
68
68
private
69
69
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 )
79
71
end
80
72
81
73
def get_info
@@ -134,10 +126,10 @@ def get_info
134
126
[ search . uniq , nameserver . uniq ]
135
127
end
136
128
137
- def get_item_property ( path , name )
129
+ def get_item_property ( path , name , expand : false )
138
130
if defined? ( Win32 ::Registry )
139
131
Registry ::HKEY_LOCAL_MACHINE . open ( path ) do |reg |
140
- reg . read_s ( key )
132
+ expand ? reg . read_s_expand ( name ) : reg . read_s ( name )
141
133
rescue Registry ::Error
142
134
""
143
135
end
You can’t perform that action at this time.
0 commit comments