WindowsInstaller 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/WindowsInstaller.rb +42 -15
- metadata +15 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e31fcaccb5e69f2740c980719dc8e3d6e562a7a2
|
4
|
+
data.tar.gz: 2499e97a98c149a8e5dde4496b72bc5310df87ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f547f75af0f2f1fec05a38f9f6baf98362d8d59d8edc4c7ceeb049f26f2a3c50367efc0a88679675e3c2856af6d9031972924d9215d7123c693f6d2104e1849c
|
7
|
+
data.tar.gz: 5e5c0cb29ffdd11b546fe351bea8de693a5e304ce57871908d5d864ab978083a81645ac48ae770ef1b8c3ae148296328aa7b3a090f67f21f641cb6beba7359f2
|
data/lib/WindowsInstaller.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
require 'win32ole'
|
2
2
|
require 'cmd'
|
3
|
+
require 'sys/proctable'
|
3
4
|
|
4
5
|
class WindowsInstaller < Hash
|
6
|
+
@@default_options = {mode: '/passive'}
|
7
|
+
|
5
8
|
def initialize(options = {})
|
9
|
+
@@default_options.each { |key, value| self[key] = value }
|
6
10
|
options.each { |key, value| self[key] = value}
|
7
11
|
end
|
8
12
|
|
13
|
+
def self.default_options(hash)
|
14
|
+
hash.each { |key,value| @@default_options[key] = value }
|
15
|
+
end
|
16
|
+
|
9
17
|
def msi_installed?(msi_file)
|
10
18
|
info = msi_properties(msi_file)
|
11
19
|
return product_code_installed?(info['ProductCode'])
|
@@ -20,17 +28,13 @@ class WindowsInstaller < Hash
|
|
20
28
|
def install_msi(msi_file)
|
21
29
|
raise "#{msi_file} does not exist!" unless(File.exists?(msi_file))
|
22
30
|
|
23
|
-
msi_file = msi_file.gsub(/\//, '\\')
|
31
|
+
msi_file = File.absolute_path(msi_file).gsub(/\//, '\\')
|
24
32
|
|
25
33
|
cmd = "msiexec.exe"
|
26
|
-
|
27
|
-
|
28
|
-
cmd = "#{cmd} /i \"#{msi_file}\""
|
34
|
+
cmd = "#{cmd} #{self[:mode]}" if(has_key?(:mode))
|
35
|
+
cmd = "#{cmd} /i #{msi_file}"
|
29
36
|
|
30
|
-
|
31
|
-
cmd_options[:admin_user] = self[:admin_user] if(has_key?(:admin_user))
|
32
|
-
command = CMD.new(cmd, cmd_options)
|
33
|
-
command.execute
|
37
|
+
msiexec(cmd)
|
34
38
|
end
|
35
39
|
|
36
40
|
def uninstall_msi(msi_file)
|
@@ -43,14 +47,9 @@ class WindowsInstaller < Hash
|
|
43
47
|
raise "#{product_code} is not installed" unless(product_code_installed?(product_code))
|
44
48
|
|
45
49
|
cmd = "msiexec.exe"
|
46
|
-
|
47
|
-
cmd = "#{cmd} /passive" if(has_key?(:mode) && (self[:mode] == :passive))
|
50
|
+
cmd = "#{cmd} #{self[:mode]}" if(has_key?(:mode))
|
48
51
|
cmd = "#{cmd} /x #{product_code}"
|
49
|
-
|
50
|
-
cmd_options = {quiet: true}
|
51
|
-
cmd_options[:admin_user] = self[:admin_user] if(has_key?(:admin_user))
|
52
|
-
command = CMD.new(cmd, cmd_options)
|
53
|
-
command.execute
|
52
|
+
msiexec(cmd)
|
54
53
|
end
|
55
54
|
|
56
55
|
private
|
@@ -81,4 +80,32 @@ class WindowsInstaller < Hash
|
|
81
80
|
|
82
81
|
return properties
|
83
82
|
end
|
83
|
+
|
84
|
+
def msiexec(cmd)
|
85
|
+
cmd = "runas /noprofile /savecred /user:#{self[:administrative_user]} \"#{cmd}\"" if(self.has_key?(:administrative_user))
|
86
|
+
|
87
|
+
cmd_options = { echo_command: false, echo_output: false} unless(self[:debug])
|
88
|
+
|
89
|
+
pre_execute = Sys::ProcTable.ps
|
90
|
+
|
91
|
+
pre_pids = {}
|
92
|
+
pre_execute.each { |ps| pre_pids[ps.pid] = ps }
|
93
|
+
|
94
|
+
command = CMD.new(cmd, cmd_options)
|
95
|
+
command.execute
|
96
|
+
|
97
|
+
msiexe_pid = 0
|
98
|
+
post_execute = Sys::ProcTable.ps
|
99
|
+
post_execute.each do |ps|
|
100
|
+
msiexe_pid = ps.pid if((ps.name.downcase == "msiexec.exe") && !pre_pids.has_key?(ps.pid))
|
101
|
+
end
|
102
|
+
|
103
|
+
if(msiexe_pid != 0)
|
104
|
+
loop do
|
105
|
+
s = Sys::ProcTable.ps(msiexe_pid)
|
106
|
+
break if(s.nil?)
|
107
|
+
sleep(1)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
84
111
|
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: WindowsInstaller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: dev
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: execute
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Class wrapper for Microsoft Windows WindowsInstaller object
|
@@ -98,19 +98,18 @@ require_paths:
|
|
98
98
|
- lib
|
99
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 1.9.1
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.4.5
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Class wrapper for Microsoft Windows WindowsInstaller object
|
115
115
|
test_files: []
|
116
|
-
has_rdoc:
|