WindowsInstaller 0.1.7 → 0.1.8

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 +24 -41
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd879c87274fbea755e4c580a96ff78f2d8a394c
4
- data.tar.gz: fc5b02582947c81dfe892490ee4cc4970b9913a1
3
+ metadata.gz: ed4c11b8ab31668f99fdde77e82b442dfdbd85ab
4
+ data.tar.gz: d9fd41348525b7a3efbc85cb241e513a50ee81fd
5
5
  SHA512:
6
- metadata.gz: cdacfe3fef17751824e598202fb71ab216188ce7e55f3b33af015183e2c2d1337380fe335e45f82d22c520314782b90452ae42297b02fa7a4b3b4eea7597c625
7
- data.tar.gz: eea56240bdecc482e6ae1ca04bc965aac6f884773bb2f0e4b106e93e48fe25ccdb30e9b44aa33c69e48d6881ee3cee527a4a52e159494913c8db8628f8977725
6
+ metadata.gz: 6ff033255a4bbd424330a44ac16a8cd87e31aa4b9182c312ae99d22e6fc292cc295e5ffccefc3a91c857af7652963a66c19247639c68e2a83269d8104c226cf0
7
+ data.tar.gz: ed5c94b06dccc63dd6414559930759bbb0c97a932ae59bb9b13b2f5470c15060b8f86e22fd9a8c88852aab80dbd58e9c1a4739ee9d555c4763c938de5f09e8f4
@@ -1,6 +1,7 @@
1
1
  require 'win32ole'
2
- require 'cmd'
2
+ require 'cmd_windows'
3
3
  require 'sys/proctable'
4
+ require 'tempfile'
4
5
 
5
6
  class WindowsInstaller < Hash
6
7
  @@default_options = {mode: '/passive'}
@@ -14,7 +15,7 @@ class WindowsInstaller < Hash
14
15
  hash.each { |key,value| @@default_options[key] = value }
15
16
  end
16
17
 
17
- def msi_installed?(msi_file)
18
+ def msi_installed?(msi_file)
18
19
  info = msi_properties(msi_file)
19
20
  return product_code_installed?(info['ProductCode'])
20
21
  end
@@ -96,50 +97,32 @@ class WindowsInstaller < Hash
96
97
 
97
98
  installer.ole_free
98
99
  installer = nil
99
-
100
+
100
101
  return properties
101
102
  end
102
103
 
103
- def msiexec(cmd)
104
- cmd_options = { echo_command: false, echo_output: false} unless(self[:debug])
105
- if(self.has_key?(:administrative_user))
106
- msiexec_admin(cmd, cmd_options)
107
- else
108
- command = CMD.new(cmd, cmd_options)
109
- command.execute
110
- end
111
- end
112
-
113
- def msiexec_admin(cmd, options)
114
- cmd = "runas /noprofile /savecred /user:#{self[:administrative_user]} \"#{cmd}\""
115
- command = CMD.new(cmd, options)
116
- wait_on_spawned(cmd) { cmd.execute }
104
+ def msiexec(command)
105
+ cmd = CMD.new(command)
106
+ cmd.execute
117
107
  end
118
108
 
119
- def wait_on_spawned_process(cmd)
120
- pre_execute = Sys::ProcTable.ps
121
-
122
- pre_pids = []
123
- pre_execute.each { |ps| pre_pids << ps.pid }
124
-
125
- yield
109
+ private
110
+ def msiexec_block
111
+ original_value = '0'
112
+ raise ':administrative_user must be set to setup always_install_elevated priviledges' if(self[:always_installed_elevated] && self.has_key?[:administrative_user])
113
+ register_reg_file('1') if(self[:always_install_elevated])
114
+ yield
115
+ register_reg_file(current_value) if(self[:always_install_elevated])
116
+ end
126
117
 
127
- exe = cmd[:command].match(/\\(?<path>.+\.exe)/i).named_captures['path']
128
- exe = File.basename(exe)
129
- #puts "Exe: #{exe}"
118
+ def register_reg_file(value)
119
+ lib_directory = File.dirname(__FILE__)
120
+ reg_file = File.read("#{lib_directory}/always_install_elevated_template.reg")
121
+ reg_file=reg_file.gsub(/VALUE/,value)
122
+ file = Tempfile.new('wininst')
123
+ file.write(reg_file)
130
124
 
131
- msiexe_pid = 0
132
- post_execute = Sys::ProcTable.ps
133
- post_execute.each do |ps|
134
- msiexe_pid = ps.pid if((ps.name.downcase == exe.downcase) && pre_pids.index(ps.pid).nil?)
135
- end
136
-
137
- if(msiexe_pid != 0)
138
- loop do
139
- s = Sys::ProcTable.ps(msiexe_pid)
140
- break if(s.nil?)
141
- sleep(1)
142
- end
143
- end
144
- end
125
+ cmd = CMD.new("#{ENV['SystemRoot']}\\System32\\regedit.exe /s #{file.path}", { echo_command: true })
126
+ cmd.execute_as(self[:administrative_user])
127
+ end
145
128
  end
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.7
4
+ version: 0.1.8
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-08-28 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler