WindowsInstaller 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/WindowsInstaller.rb +37 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50168f29934c54d5055263e042a07814d3479e2f
4
- data.tar.gz: 6497bc6f5c0d0be1059fa99bc0c3c7b69c10527a
3
+ metadata.gz: b7fd5c6b3bb1348c6ed0594ed92209a7d62f7c15
4
+ data.tar.gz: f86696a2ac7e66865941c57b829f501b23080d5d
5
5
  SHA512:
6
- metadata.gz: 5098c0504690cdb14bfb61d53bad1222db49012239cb5d2fbe2c0e643c178889c601f9f4bfd5723e24003a8bf6261f406d60c21115e4cb42f294ea20994753e2
7
- data.tar.gz: 490ad8022478cc9661e7a6f138b9acfd206789f4800552a6f951937a93e764889a1222ac5a017ffcfc5842f3c01d1ea001928130ef010d14f42fd41467d430a9
6
+ metadata.gz: c9087e8ff74556064ec00d6efd9ebd9a34b4c966db06c97b3611733894fdbfa6edb5f83d0d60dfbb37b76362b2cd0af5f4e05995537de3e0ea8ede5c8148829b
7
+ data.tar.gz: b70351ba9c03a8426ef253e7191ee0779eef319a024958b7eae8b3fa368de21849ee340fabc3b79b61da855cc436540348acaa2ff8c45f75d78f1e338bcfecd0
@@ -96,13 +96,22 @@ class WindowsInstaller < Hash
96
96
  end
97
97
 
98
98
  def installation_properties(product_name_or_product_code)
99
- properties = installed_properties(product_name_or_product_code)
100
- return properties unless(properties.nil?)
99
+ product_code = product_name_or_product_code
100
+ properties = installed_properties(product_code)
101
+ if(properties.nil?)
102
+ product_name = product_name_or_product_code
103
+ product_code = installed_get_product_code(product_name)
104
+ return nil if(product_code == '')
101
105
 
102
- product_code = installed_get_product_code(product_name_or_product_code)
103
- return nil if(product_code == '')
106
+ properties = installed_properties(product_code)
107
+ end
108
+
109
+ return nil if(properties.nil?)
104
110
 
105
- return installed_properties(product_code)
111
+ upgrade_code = get_upgrade_code(product_code)
112
+ properties['UpgradeCode'] = upgrade_code unless(upgrade_code.nil?)
113
+
114
+ return properties
106
115
  end
107
116
 
108
117
  private
@@ -132,6 +141,28 @@ class WindowsInstaller < Hash
132
141
  return hash
133
142
  end
134
143
 
144
+ def get_upgrade_code(product_code)
145
+ return nil if(!product_code_installed?(product_code))
146
+
147
+ property_value = @installer.ProductsEx('','',7).each do |prod|
148
+ begin
149
+ local_pkg = prod.InstallProperty('LocalPackage')
150
+ rescue
151
+ next
152
+ end
153
+ db = @installer.OpenDataBase(local_pkg, 0)
154
+ query = 'SELECT `Value` FROM `Property` WHERE `Property` = \'UpgradeCode\''
155
+ view = db.OpenView(query)
156
+ view.Execute
157
+ record = view.Fetch
158
+ unless(record.nil?)
159
+ upgrade_code = record.StringData(1)
160
+ return upgrade_code if(prod.ProductCode == product_code)
161
+ end
162
+ end
163
+ return nil
164
+ end
165
+
135
166
  def msiexec(cmd)
136
167
  cmd_options = { echo_command: false, echo_output: false} unless(self[:debug])
137
168
  if(self.has_key?(:administrative_user))
@@ -141,7 +172,7 @@ class WindowsInstaller < Hash
141
172
  command.execute
142
173
  end
143
174
  end
144
-
175
+
145
176
  def msiexec_admin(cmd, options)
146
177
  cmd = "runas /noprofile /savecred /user:#{self[:administrative_user]} \"#{cmd}\""
147
178
  command = CMD.new(cmd, options)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: WindowsInstaller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler